LoginSignup
4
4

More than 5 years have passed since last update.

bashの出力なリダイレクトとパイプ周りのまとめ

Posted at

出力

stdout
$ command >&1

stderr
$ command >&2

ファイル出力

stdoutをファイルに
$ command >  file

stderrをファイルに
$ command 2> file

stdout/stdinどっちもファイルに
$ command >  file 2>&1

bash依存系

stdout+stdin ファイル出力省略系
$ command &>  file
$ command &>> file  (append)

stdout+stdin パイプに渡す
$ command1 |& command2

標準エラーだけパイプに渡す
$ command1 > /dev/null |& command2

noclobber 環境下での強制上書き
$ command >| file
4
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
4
4