Piping error messages with grep

前端 未结 2 1376
独厮守ぢ
独厮守ぢ 2021-01-21 15:14

I have a script that fails because some files are missing.

Running the script and piping it to grep

$ ./adder | grep Error

produces th

2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-21 15:42

    You need to redirect standard error stream (numeric code: 2) from first command in the pipe to standard output stream (numeric code: 1), like this:

    $ ./adder 2>&1 | grep Error
    

提交回复
热议问题