首页 > 系统服务 > 详细

linux基础篇-11,IO重定向和管道

时间:2016-11-23 08:31:36      阅读:267      评论:0      收藏:0      [点我收藏+]

################################################


>:覆盖输出 

》追加输出


set -c :禁止覆盖

set +c:关闭禁用覆盖


################################################


2>:重定向错误覆盖

2》:重定向错误追加输出


################################################


&>:错误正确都重定向到一个文件


[root@Jameszhan testcp]# ls /homes &> /tmp/t1.txt ls /home&> /tmp/t1.txt

[root@Jameszhan testcp]# cat /tmp/t1.txt 

ls: 无法访问/homes: 没有那个文件或目录

ls: 无法访问ls: 没有那个文件或目录

/home:

james

jameszhan

Jameszhan

lost+found

newtest

testcp

[root@Jameszhan testcp]# vim /tmp/t1.txt


ls: 无法访问/homes: 没有那个文件或目录

ls: 无法访问ls: 没有那个文件或目录

/home:

james

jameszhan

Jameszhan

lost+found

newtest

testcp


################################################


<:输入重定向

《:Here Document


################################################


管道


命令1 | 命令2 | 命令3 | ...




tee:把标准输入的内容保存到文件中,并标准输出到屏幕


[root@Jameszhan testcp]# echo ‘hello‘ | tee /tmp/hello.txt

hello


[root@Jameszhan testcp]# cat /tmp/hello.txt 

hello


[root@Jameszhan testcp]# wc -l /etc/passwd | cut -d ‘ ‘ -f1

32


本文出自 “James zhan Linux高级运维” 博客,请务必保留此出处http://jameszhan.blog.51cto.com/10980469/1875539

linux基础篇-11,IO重定向和管道

原文:http://jameszhan.blog.51cto.com/10980469/1875539

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