首页 > 系统服务 > 详细

linux学习命令总结⑨

时间:2014-08-17 17:10:33      阅读:522      评论:0      收藏:0      [点我收藏+]

#重定向

输出重定向:

1>覆盖输出(1可省略)

[root@VM_168_102_centos tmp]# ls functions >shuchu
[root@VM_168_102_centos tmp]# cat shuchu 
functions
[root@VM_168_102_centos tmp]# ls fstab >shuchu
[root@VM_168_102_centos tmp]# cat shuchu 
fstab

1>>追加输出(1可省略)

[root@VM_168_102_centos tmp]# cat shuchu 
fstab
[root@VM_168_102_centos tmp]# ls functions >>shuchu
[root@VM_168_102_centos tmp]# cat shuchu 
fstab
functions

错误重定向:

2>:覆盖输出

[root@VM_168_102_centos tmp]# ls 
agent_cmd.sock  fstab      hellodirxyz  scripttest  test
ceshi           functions  rc.sysinit   shuchu
[root@VM_168_102_centos tmp]# ls fstab wanghan >shuchu
ls: cannot access wanghan: No such file or directory
[root@VM_168_102_centos tmp]# cat shuchu 
fstab
[root@VM_168_102_centos tmp]# ls fstab wanghan 2>shuchu
fstab
[root@VM_168_102_centos tmp]# cat shuchu 
ls: cannot access wanghan: No such file or directory

2>>:追加输出

[root@VM_168_102_centos tmp]# cat shuchu               
ls: cannot access wanghan: No such file or directory
[root@VM_168_102_centos tmp]# ls ssssdd wanghan 2>>shuchu
[root@VM_168_102_centos tmp]# cat shuchu 
ls: cannot access wanghan: No such file or directory
ls: cannot access ssssdd: No such file or directory
ls: cannot access wanghan: No such file or directory

同时重定标准输出和错误输出

[root@VM_168_102_centos tmp]# ls fstab wanghan >shuchu 2>cuowu[root@VM_168_102_centos tmp]# cat shuchu 
fstab
[root@VM_168_102_centos tmp]# cat cuowu 
ls: cannot access wanghan: No such file or directory
[root@VM_168_102_centos tmp]# ls fstab wanghan &>all       
[root@VM_168_102_centos tmp]# cat all
ls: cannot access wanghan: No such file or directory
fstab
[root@VM_168_102_centos tmp]# ls fstab wanghan >both 2>&1
[root@VM_168_102_centos tmp]# cat both 
ls: cannot access wanghan: No such file or directory
fstab

linux学习命令总结⑨,布布扣,bubuko.com

linux学习命令总结⑨

原文:http://putongren.blog.51cto.com/9086263/1541272

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