問題 coverage-101500-bash-redirection-reverse・第1版

問題

command 2>&1 >out.log を実行し、元のstdoutはterminalだった。stderrの出力先はどれか。

  1. A 

    out.logへ必ず追従して変わる。

  2. B 

    元のstdoutであるterminal

  3. C 

    stdinへ逆流する。

  4. D 

    自動で削除される。

正解:B

理由

stderrを元のstdoutへ複製した後、stdoutだけfileへ変える。

選択肢ごとの説明

A.

out.logへ必ず追従して変わる。

descriptorの複製時点の対象を保持する。

B.

元のstdoutであるterminal

後のstdout変更は複製済みstderrを変えない。

C.

stdinへ逆流する。

descriptor0へ向けていない。

D.

自動で削除される。

削除・破棄の指定ではない。

参考資料

お問い合わせ

演習する →