How can I pipe stderr, and not stdout?

后端 未结 11 1315
-上瘾入骨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:12

    Combining the best of these answers, if you do:

    command 2> >(grep -v something 1>&2)

    ...then all stdout is preserved as stdout and all stderr is preserved as stderr, but you won't see any lines in stderr containing the string "something".

    This has the unique advantage of not reversing or discarding stdout and stderr, nor smushing them together, nor using any temporary files.

提交回复
热议问题