首页 > 代码库 > linux学习命令总结⑨
linux学习命令总结⑨
#重定向
输出重定向:
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
[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
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。