码迷,mamicode.com
首页 > 系统相关 > 详细

linux学习命令总结⑨

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

标签:cccccc   linux   style   定向   

#重定向

输出重定向:

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学习命令总结⑨

标签:cccccc   linux   style   定向   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!