shell-重定向

>: 重写(正确信息)
>>: 追加(正确信息)
2>: 重写(错误信息)
2>>: 追加(错误信息)
&>: 重写(全部信息)
&>>: 追加(全部信息)
实例
[root@localhost wang]# ls
123.txt  1.txt  23.txt  2.txt  3.txt  a.txt  A.txt
[root@localhost wang]# ls 123.txt >test.txt
[root@localhost wang]# cat test.txt 
123.txt
[root@localhost wang]# ls 2.txt >test.txt 
[root@localhost wang]# cat test.txt 
2.txt
[root@localhost wang]# ls a.txt >>test.txt 
[root@localhost wang]# cat test.txt 
2.txt
a.txt
[root@localhost wang]# ls h.txt 2>test.txt 
[root@localhost wang]# cat test.txt 
ls: 无法访问h.txt: 没有那个文件或目录
[root@localhost wang]# ls hahah.txt 2>>test.txt 
[root@localhost wang]# cat test.txt 
ls: 无法访问h.txt: 没有那个文件或目录
ls: 无法访问hahah.txt: 没有那个文件或目录
[root@localhost wang]# ls a.txt h.txt 1.txt &> test.txt 
[root@localhost wang]# cat test.txt 
ls: 无法访问h.txt: 没有那个文件或目录
1.txt
a.txt
[root@localhost wang]# 
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容