ローカルファイルからstdoutをキャプチャしている間にstdoutを別のプロセスにパイプする方法は?

ローカルファイルからstdoutをキャプチャしている間にstdoutを別のプロセスにパイプする方法は?

次のコマンドを使用します。

program_that_produces_stdout | program_that_captures_stdout

program_that_produces_stdoutまた、ファイルの出力をローカルにキャプチャしたいと思います。

確かに

program_that_produces_stdout | program_that_captures_stdout > some_file

うまくいかず、tee仕事に適したツールではないようです。

ベストアンサー1

tee正しい場所に正しいコマンドがあります。

 program_that_produces_stdout | tee some_file | program_that_captures_stdout

上書きする代わりに「some_file」に追加するには(「>」ではなく「>>」)、tee -a代わりに使用してください。

例えば

 program_that_produces_stdout | tee -a some_file | program_that_captures_stdout

おすすめ記事