linux重定向命令

2021-06-21 00:34:21 字數 697 閱讀 3839

昨天參加網易ttt的筆試,填空題考了cmd > file 2>&1的含義,我以前做專案接觸過重定向命令,但沒用這個,然後居然沒寫出正確答案來,

慚愧啊。。。。謹記,對遇到的問題要求甚解,要徹底弄懂,並且還要複習!

現把所有命令列出來

cmd > file 把 stdout 重定向到 file 檔案中;

cmd >> file 把 stdout 重定向到 file 檔案中(追加);

cmd 1> file 把 stdout 重定向到 file 檔案中;

cmd > file 2>&1 把 stdout 和 stderr 一起重定向到 file 檔案中;

cmd 2> file 把 stderr 重定向到 file 檔案中;

cmd 2>> file 把 stderr 重定向到 file 檔案中(追加);

cmd >> file 2>&1 把 stdout 和 stderr 一起重定向到 file 檔案中(追加);

cmd < file >file2 cmd 命令以 file 檔案作為 stdin,以 file2 檔案作為 stdout;

cat <>file 以讀寫的方式開啟 file;

cmd < file cmd 命令以 file 檔案作為 stdin;

cmd << delimiter here document,從 stdin 中讀入,直至遇到 delimiter 分界符。

linux 重定向命令

command filename 把標準輸出重定向到乙個新檔案中 command filename 把標準輸出重定向到乙個檔案中 追加 command 1 fielname 把標準輸出重定向到乙個檔案中 command filename 2 1 把標準輸出和標準錯誤一起重定向到乙個檔案中 comma...

linux 重定向命令

標準輸入,輸出和錯誤 檔案檔案 描述符 輸入檔案 標準輸入 0 輸出檔案 標準輸出 1 錯誤輸出檔案 標準錯誤 2 1.重定向 command filename 把標準輸出重定向到乙個新檔案中 command filename 把標準輸出重定向到乙個檔案中 追加 command1 fielname ...

Linux命令學習 重定向

標準輸入,輸出,和錯誤到目前為止,我們用到的許多程式都會產生某種輸出。這種輸出,經常由兩種型別組成。第一,程式執行結果 這是說,程式要完成的功能。第二,我們得到狀態和錯誤資訊,這些告訴我們程式進展。如果我們觀察乙個命令,像 ls,會看到它的執行結果和錯誤資訊 顯示在螢幕上。與 unix 主題 任何東...