pipe and redirection
標準輸入 (stdin)  是文字輸入串流,預設會附接到鍵盤
標準輸出 (stdout) 是文字輸出串流,用於正常的程式輸出
標準錯誤 (stderr)  是個額外的輸出串流,用於錯誤訊息

pipe [ | ] 將一個程式的 標準輸出(stdout) 連結到另一個程式的 標準輸入(stdin)

常見的轉向用法

轉向功能 BASH的語法
將stdout 傳送至檔案 file #cmd > file
#cmd 1> file
將stderr傳送至檔案 file
#cmd 2> file
將stdout 與 stderr 同時傳送至檔案 file
#cmd > file 2>&1
自檔案接收 stdin
#cmd < file
將stdout 附加到檔案file
#cmd >> fiel
#cmd 1>> file
將stderr附加到檔案file
cmd 2>> file
將stdout 與 stderr 同時附加到檔案file
#cmd >> file 2>&1
將命令com1 之 stdout 以導管連接至(pipe to)命令 com2
#cmd1 | cmd2
將命令com1 之 stdout 與 stderr 以導管連接至命令 com2
#cmd1 2>&1 | cmd2
將命令 com1 之 stdout 以導管連接至命令 com2 ,同時並使用tee將它(cmd1 之 stdout ) 寫入 file1
#ccmd1 tee file1 | cmd2