假設兩個文件 test.sh
存在和test1.sh
不存在
ls test.sh test1.sh 1>svc.txt
把正確輸出重定向到文件svc.txtls test.sh test1.sh 1>svc.txt 2>err.txt
把正確輸出重定向到文件svc.txt,把錯誤輸出重定向到文件err.txtls test.sh test1.sh 2>&- 或者 ls test.sh test1.sh 2>/dev/null
把錯誤輸出關閉掉,不輸出錯誤信息ls test.sh test1.sh 1>&- 2>&- 或者 ls test.sh test1.sh 1>/dev/null 2>/dev/null 或者 ls test.sh test1.sh &>/dev/null
關閉正確輸出和錯誤輸出ls test.sh test1.sh >/dev/null 2>&1
將正確輸出關閉,錯誤輸出重定向到正確輸出使用的設備上去