LoginSignup
0
0

More than 3 years have passed since last update.

error messageをgrepする

Posted at

何らかのerror出力がうるさくてgrepしたい場合, よく使うpipe|はerror出力を渡さないため, 渡すように|&に変更する必要があります1.

./a.out |& grep "hoge"

標準出力をgrepに渡したくない場合(error出力のみをgrepに渡したい場合)

|&は標準出力とerror出力の両方を渡すため, 標準出力の情報がerror出力の情報を汚染してしまう場合, 標準出力を捨てる必要があります2.

 (./a.out > /dev/null) |& grep "hoge" 

参考

パイプとリダイレクトでコマンドを組み合わせて実行しよう (4/4)


  1. pipeの使い方を知っていれば自明ですが, 直接的な情報が見つからなかったので書きました. 

  2. redirect 2> のように簡単にerrorのみを出力する方法はありません. 

0
0
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
0
0