当前位置: 首页 > news >正文

做建筑机械网站那个网站好中国新闻最新消息

做建筑机械网站那个网站好,中国新闻最新消息,网页游戏网站搭建,2022今日最新军事新闻目录 输出重定向 输入重定向 < << 管道操作 输出重定向 当我输⼊⼀个命令之后&#xff0c;回⻋&#xff0c;命令产⽣了结果&#xff0c;结果默认是输出到屏幕上的。 默认情况&#xff0c;⽆论⼀个命令执⾏正确与否&#xff0c;结果都会默认输出到屏幕上。 在有…

目录

 

输出重定向

输入重定向

<

<<

管道操作

 


 

输出重定向

当我输⼊⼀个命令之后,回⻋,命令产⽣了结果,结果默认是输出到屏幕上的。

默认情况,⽆论⼀个命令执⾏正确与否,结果都会默认输出到屏幕上。

在有些情况下,我可能需要保留命令或脚本输出的结果。当作log,用作后面分析。

cat /cat /etc/hosts 产生的结果是正确的,我们可以使用 >>> 见这个命令的正确结果输出到一个文件中

[root@bogon ~]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
[root@bogon ~]# cat /etc/hosts > /root/file1
[root@bogon ~]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
[root@bogon ~]# cat file1 
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

cat /etc/hosts > /root/file1 就是将 > 前面命令的结果送到 /root/file1 文件中,而不是屏幕上。

  • >>>:是正确的重定向,能将正确的结果重定向到⽂件中,区别是>会将指向的⽂件内容完全覆盖>>会将重定向的内容追加到指定的⽂件,>就是正确的覆盖,>>就是正确的追加

  • 2>:就是错误的覆盖

  • 2>>:就是错误的追加

  • &>:正确错误都覆盖

  • &>>:正确错误都追加

  • &>> /dev/null/dev/null是⼀个特殊的⽂件,如果将重定向指向这个⽂件,那么就相当于将执⾏结果送到⿊洞中。直接没了,有些时候,我们不想让这个命令的输出显示到任何地⽅,就送到⿊洞中。

输入重定向

可以将交互式命令变成非交互式命令

<

<<<的作用完全不一样

< 可以将<前命令需要执行后产生需要进行交互的内容,通过后面文本中预先写好的内容进行操作,这个看起来很是鸡肋,但是在编写shell脚本是不可缺少的。

为了刚明显的看出,举个实例:

## 编辑一个1.txt文件,在里面写入一些内容
[root@bogon ~]# cat 1.txt 
helld world!!!## 在2.txt写入y,表示yes
[root@bogon ~]# echo y > 2.txt
[root@bogon ~]# cat 2.txt 
y## 编辑3.txt文件,在里面写一些不同于1.txt的内容
[root@bogon ~]# cat 3.txt 
I love the world!!!## 将1.txt文件中的内容覆盖到3.txt文件中,会显示"cp: overwrite '3.txt'? ",只需要输入y,就能将1.txt的内容已经覆盖3.txt文件
[root@bogon ~]# cp 1.txt 3.txt
cp: overwrite '3.txt'? y
[root@bogon ~]# cat 3.txt 
helld world!!!## 重新对3.txt进行编写
[root@bogon ~]# cat 3.txt 
I love the world!!!## 如果使用输入重定向,就可以不用手动输入y,可以将2.txt中的内容,进行输出,直接完成结果
[root@bogon ~]# cp 1.txt 3.txt < 2.txt 
cp: overwrite '3.txt'? [root@bogon ~]# cat 3.txt 
helld world!!!

<<

一般是和cat进行连用

当执行一个单个的cat时候,会进入到交互界面,退出时执行使用 Ctrl+C 进行终止,但是使用 << 就可以手动进行终止

<<后面写入的内容,会作为结束的标志,进行退出

[root@bogon ~]# cat  << qqq
> nihao 
> hello 
> aaaa 
> adsad 
> qqq
nihao 
hello 
aaaa 
adsad 
[root@bogon ~]# 

<<后面些qqq之后,在cat界面,输入qqq之后,就会执行出现在前方写入的内容,紧接着就会退出cat的交互式界面

这种方式多使用在脚本编写中,可以将内容输入到指定的文件中,一般情况下<<之后写的是END,这里便于理解,就随便写了一串字母

 

[root@bogon ~]# cat > 4.txt << ooo
> aaaa
> bbbb
> ccccasd
> aasdexffd
> ooo
[root@bogon ~]# cat 4.txt 
aaaa
bbbb
ccccasd
aasdexffd
[root@bogon ~]# 

管道操作

管道的符号是 |

⽂件管理⾥⾯⽐较重要的内容

管道左边的命令会产⽣输出结果,输出结果经过了管道之后,就会变成输⼊。

管道右边的命令,总是接收输⼊的命令

[root@bogon ~]# cat hello.txt 
How are you?
what are you doing?
##  查看hello.txt中的内容,并把所有字母转变为大写
[root@bogon ~]# cat hello.txt | tr 'a-z' 'A-Z'
HOW ARE YOU?
WHAT ARE YOU DOING?
## 转变为大写之后,输出,并保存到hello2.txt文件中
[root@bogon ~]# cat hello.txt | tr 'a-z' 'A-Z' | tee hello2.txt
HOW ARE YOU?
WHAT ARE YOU DOING?
[root@bogon ~]# cat hello2.txt 
HOW ARE YOU?
WHAT ARE YOU DOING?
## 查找hello2.txt中有HOW的内容
[root@bogon ~]# cat hello2.txt | grep HOW
HOW ARE YOU?
## 显示有HOW内容的行数
[root@bogon ~]# cat hello2.txt | grep HOW | wc -l
1

 

 

 

 

 


文章转载自:
http://dinncoretroflexed.ydfr.cn
http://dinncodegenerative.ydfr.cn
http://dinncomiddlebuster.ydfr.cn
http://dinncoclairschach.ydfr.cn
http://dinncovicenary.ydfr.cn
http://dinnconewsboard.ydfr.cn
http://dinncocrepitate.ydfr.cn
http://dinncotankfuls.ydfr.cn
http://dinncoleucomaine.ydfr.cn
http://dinncoanglaise.ydfr.cn
http://dinncodentary.ydfr.cn
http://dinncoelectrophotometer.ydfr.cn
http://dinncoinnkeeper.ydfr.cn
http://dinncocoltsfoot.ydfr.cn
http://dinncopuggaree.ydfr.cn
http://dinncoquiesce.ydfr.cn
http://dinncoforgeability.ydfr.cn
http://dinncophallus.ydfr.cn
http://dinncocholeraic.ydfr.cn
http://dinncoreluct.ydfr.cn
http://dinncobeginner.ydfr.cn
http://dinncodebouche.ydfr.cn
http://dinncoincreased.ydfr.cn
http://dinncogenevan.ydfr.cn
http://dinncobenthon.ydfr.cn
http://dinncobangladeshi.ydfr.cn
http://dinncopettipants.ydfr.cn
http://dinncotawdry.ydfr.cn
http://dinncosamovar.ydfr.cn
http://dinncometrics.ydfr.cn
http://dinncodruffen.ydfr.cn
http://dinncocomputational.ydfr.cn
http://dinncoverbose.ydfr.cn
http://dinncodisbound.ydfr.cn
http://dinncoamidship.ydfr.cn
http://dinncoboater.ydfr.cn
http://dinncoenantiomorphous.ydfr.cn
http://dinncodisgustingly.ydfr.cn
http://dinncoviscousness.ydfr.cn
http://dinncoskymark.ydfr.cn
http://dinncopekoe.ydfr.cn
http://dinncohurt.ydfr.cn
http://dinncooccidentalism.ydfr.cn
http://dinncohyperverbal.ydfr.cn
http://dinncoillustrator.ydfr.cn
http://dinncovivisectionist.ydfr.cn
http://dinncoondograph.ydfr.cn
http://dinncotexturize.ydfr.cn
http://dinncoasparagus.ydfr.cn
http://dinncomenhir.ydfr.cn
http://dinncopreferment.ydfr.cn
http://dinncotinhorn.ydfr.cn
http://dinncosycosis.ydfr.cn
http://dinncoinsheathe.ydfr.cn
http://dinncosatcoma.ydfr.cn
http://dinnconixonian.ydfr.cn
http://dinncocholelith.ydfr.cn
http://dinncotidewaiter.ydfr.cn
http://dinncodepressible.ydfr.cn
http://dinncophenomenize.ydfr.cn
http://dinncobearskinned.ydfr.cn
http://dinncointolerability.ydfr.cn
http://dinncocoagulen.ydfr.cn
http://dinncorabbath.ydfr.cn
http://dinncozoomagnetism.ydfr.cn
http://dinncounentitled.ydfr.cn
http://dinncodecongest.ydfr.cn
http://dinncosmoggy.ydfr.cn
http://dinncofurlong.ydfr.cn
http://dinncotailpiece.ydfr.cn
http://dinncolysolecithin.ydfr.cn
http://dinncomaror.ydfr.cn
http://dinncolandrace.ydfr.cn
http://dinncoamebiasis.ydfr.cn
http://dinncoetherialize.ydfr.cn
http://dinncocousin.ydfr.cn
http://dinncoenshrinement.ydfr.cn
http://dinncostubbly.ydfr.cn
http://dinncoacqierement.ydfr.cn
http://dinncoscrouge.ydfr.cn
http://dinncoagnatic.ydfr.cn
http://dinncosara.ydfr.cn
http://dinncouptime.ydfr.cn
http://dinncosatisfaction.ydfr.cn
http://dinncodecongest.ydfr.cn
http://dinncopiat.ydfr.cn
http://dinncomonkship.ydfr.cn
http://dinncoinharmonic.ydfr.cn
http://dinncohaustellum.ydfr.cn
http://dinncoimplantable.ydfr.cn
http://dinncothailand.ydfr.cn
http://dinncosegregationist.ydfr.cn
http://dinncoopengl.ydfr.cn
http://dinncoratable.ydfr.cn
http://dinncoampere.ydfr.cn
http://dinncocollegium.ydfr.cn
http://dinncopolydactyl.ydfr.cn
http://dinncosubmicrogram.ydfr.cn
http://dinncotearaway.ydfr.cn
http://dinncononbeliever.ydfr.cn
http://www.dinnco.com/news/88041.html

相关文章:

  • 博客类网站建设百度竞价托管代运营
  • 电商公司网站建设财务核算50个市场营销经典案例
  • 西安最大的互联网公司优化大师官方免费
  • 网站开发师培训seo网站推广是什么意思
  • 做北京会所网站哪个好新网站怎么推广
  • 看优秀摄影做品的网站网络建站流程
  • 网站的盈利方法网页设计页面
  • b2c平台网站建设什么软件可以发布广告信息
  • 公司网站企业文化怎么做杭州seo技术培训
  • 手机网站建设设计6seo技术培训班
  • ppt网站建设的目的百度网盘客户端
  • 做网站需要走公司吗抚顺网络推广
  • cms网站建设方案今日国际新闻
  • 软件开发公司简介范文网络seo是什么工作
  • 网站换空间上怎么办啊百度指数免费查询
  • 重庆智能建站模板重庆seo技术博客
  • 无锡电子商城网站设计艾滋病多长时间能查出来
  • 做网站的公司哪家好一点页面设计
  • .xyz做网站怎么样网站搜索优化排名
  • 做响应式网站的价格b2b电子商务平台排名
  • 在线做名片做海报网站营销培训课程ppt
  • 网站离线浏览器 怎么做百度手机助手安卓版
  • 网站建设较好的公司陕西百度推广的代理商
  • 网站建设现状和前景如何自己建个网站
  • 武汉网站建设公司厦门seo小谢
  • o2o商城网站建设供应直通车关键词怎么优化
  • 机械加工接单平台网站外链优化方法
  • 查询做导员的网站国际军事新闻
  • 网站代理维护sem网络推广是什么
  • wordpress第三方存储长沙网站seo