首页 > 其他 > 详细

输入输出重定向

时间:2020-05-13 09:07:15      阅读:53      评论:0      收藏:0      [点我收藏+]

>, < 表示数据的流动方向,比如

command < inputfile  #表示把 inputfile 中的内容作为标准输入(STDIN)提供给 command
command > outputfile #表示把 command 产生的标准输出(STDOUT)导进 outputfile 中保存。如果 outputfile 不存在,就自动创建,如果已存在,就擦除旧内容然后写入。

>> 表示向文件中追加数据

command >> outputfile #会把 command 产生的标准输出 ( STDOUT ) 导进 outputfile, 追加到 outputfile 已有的内容后面。

<< 表示内联输入重定向(inline input redirection),需要一个文本标记来划分输入数据的开始和结尾

command << input #这里 input 就是“文本标记”,此后的内容就是输入,导向标准输入(STDIN)
xxxxx
xxxxx
xxxxx
input # 结束重定向

| 表示管道

command1 | command2 # command1 每产生一行标准输出 (STDOUT),立即重定向,作为输出流向 command2
ls | sort | more # ls 的结果重定向给 sort,然后给 moremore 显示第一页结果,如果需要更多结果则往下滚动。

 

输入输出重定向

原文:https://www.cnblogs.com/luyi07/p/12879982.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!