Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
プログラムの出力を画面に表示し、それらをLinuxのログファイルに入れたいと思っています。
<program> 2>&1 | tee logfile
また
<program> |& tee logfile
確かに、彼らは私が望むことを行うことができますが、出力は画面に表示されずvim、プログラムが終了するまでログファイルが表示されても何も表示されません
vim
この問題に対処するには?
ありがとう!
そのコマンドを実行できます:
script -f -c "program" logfile
これにより、プログラムが起動し、標準出力とエラー ストリームの両方が、バッファーなしでログ ファイルに記録されます。
欠点の 1 つは、stdin も出力に表示されることです (画面にエコーされない場合を除く) が、これは便利な機能である可能性があります。