#重定向
输出重定向:
1>覆盖输出(1可省略)
[[email protected]_168_102_centos tmp]# ls functions >shuchu [[email protected]_168_102_centos tmp]# cat shuchu functions [[email protected]_168_102_centos tmp]# ls fstab >shuchu [[email protected]_168_102_centos tmp]# cat shuchu fstab
1>>追加输出(1可省略)
[[email protected]_168_102_centos tmp]# cat shuchu fstab [[email protected]_168_102_centos tmp]# ls functions >>shuchu [[email protected]_168_102_centos tmp]# cat shuchu fstab functions
错误重定向:
2>:覆盖输出
[[email protected]_168_102_centos tmp]# ls agent_cmd.sock fstab hellodirxyz scripttest test ceshi functions rc.sysinit shuchu [[email protected]_168_102_centos tmp]# ls fstab wanghan >shuchu ls: cannot access wanghan: No such file or directory [[email protected]_168_102_centos tmp]# cat shuchu fstab [[email protected]_168_102_centos tmp]# ls fstab wanghan 2>shuchu fstab [[email protected]_168_102_centos tmp]# cat shuchu ls: cannot access wanghan: No such file or directory
2>>:追加输出
[[email protected]_168_102_centos tmp]# cat shuchu ls: cannot access wanghan: No such file or directory [[email protected]_168_102_centos tmp]# ls ssssdd wanghan 2>>shuchu [[email protected]_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
同时重定标准输出和错误输出:
[[email protected]_168_102_centos tmp]# ls fstab wanghan >shuchu 2>cuowu[[email protected]_168_102_centos tmp]# cat shuchu fstab [[email protected]_168_102_centos tmp]# cat cuowu ls: cannot access wanghan: No such file or directory
[[email protected]_168_102_centos tmp]# ls fstab wanghan &>all [[email protected]_168_102_centos tmp]# cat all ls: cannot access wanghan: No such file or directory fstab
[[email protected]_168_102_centos tmp]# ls fstab wanghan >both 2>&1 [[email protected]_168_102_centos tmp]# cat both ls: cannot access wanghan: No such file or directory fstab
linux学习命令总结⑨
时间: 2024-10-13 10:48:26