输入输出重定向

把所有 标准输出 和 标准错误输出 都输出到文件(屏幕无输出):

ls file1 non-file > ./out.log 2>&1

 

同上:

ls file1 non-file 1> ./out.log 2>&1

 

有时候会看到1>&2,但是第一个就不能简写了:

ls file1 non-file 2> ./out.log 1>&2

 

如果写反了,那错误信息就输出在屏幕上,标准输出在out.log里:

ls file1 non-file 2>&1 > ./out.log

 

把所有 标准输出 和 标准错误输出 都扔到垃圾桶里面:

ls file1 non-file > /dev/null 2>&1

 

简写,把标准输出和错误一起输出到文件:

 ls file1 non-file >& ./out.put

或 ls file1 non-file &> ./out.put

posted @ 2017-08-09 16:02  dongdonggeorge  阅读(162)  评论(0编辑  收藏  举报