My program outputs to stderr
and stdout
. I want to grep for "pattern" either in stderr
and stdout
. And I want the rest to be sent to /dev/null
.
If I pipe after redirect stderr
: ./prog 2>/dev/null | grep "pattern"
I don't get the lines of stderr
that contain "pattern".
If I pipe before redirecting stderr
: ./prog | grep "pattern" 2>/dev/null
none of stderr
is redirected to /dev/null
thank you for your help.
/prog | grep "pattern"
automatically.