Which of the following statements is correct regarding the command foo 1> bar?

A. The stdout from the command foo is appended to the file bar.
B. The stdout from the command foo overwrites the file bar.
C. The command foo receives its stdin from the file bar.
D. The command foo receives its stdin from the stdout of the command bar.
E. The stderr from the command foo is saved to the file bar.

題解

「1> bar」會將標準輸出串流的訊息導給「bar」檔案。會覆蓋原本的bar」檔案。因此選項B是正確答案。

若要將新的訊息接在「bar」檔案原本的內容之後,應使用「1>> bar」,如此一來答案就會是選項A了。