How can I pipe stderr, and not stdout?

后端 未结 11 1176
-上瘾入骨i
-上瘾入骨i 2020-11-22 03:28

I have a program that writes information to stdout and stderr, and I need to process the stderr with grep, leaving

11条回答
  •  长情又很酷
    2020-11-22 04:14

    In Bash, you can also redirect to a subshell using process substitution:

    command > >(stdlog pipe)  2> >(stderr pipe)
    

    For the case at hand:

    command 2> >(grep 'something') >/dev/null
    

提交回复
热议问题