6
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

stdoutとstderrをそれぞれ別々にteeする方法

Posted at

備忘録。

経緯

  • bashスクリプトのログを後で確認しやすいよう stdoutstderr に分けて出力したい
  • 実装の時の動作確認では直接実行するので、両方ともコンソールで確認したい

という時に使える小ネタ。

方法

>(...) の記法(process substitutionと言うらしい)を用いてそれぞれの出力を別プロセス上でteeしてファイルと出力元に書き戻す。

$ some-script.sh 1> >(tee out.log >&1) 2> >(tee err.log >&2)

参考

6
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?