cat <<-EOF >&2
cat >&2 <==> cat 1>&2 標准輸出被重定向到錯誤輸出 默認屏幕
<替換 <<累加
標准輸入:代碼為0 < <<
標准輸出:代碼為1 > >> 默認屏幕
標准錯誤輸出:代碼為2 2> 2>> 默認屏幕
find /home -name .bashrc > list_right 2> list_error #省略了1 1> list_right
find /home -name .bashrc > list 2> list #錯誤 兩條數據寫入同一個文件,交叉寫入,次序錯亂
find /home -name .bashrc > list 2>&1 #正確
區別:
1)cat food 2>&1 >file :錯誤輸出到終端,標准輸出被重定向到文件file。
2)cat food >file 2>&1 :標准輸出被重定向到文件file,然后錯誤輸出也重定向到和標准輸出一樣,所以也錯誤輸出到文件file。