3
I'm using command | grep -v "JavaScript strict warning"
to filter the output of a command (hiding warnings). The grep command works fine when I test it like this:
$ printf "JavaScript strict warning: warning\nNot a warning\nJavaScript strict warning: warning\nJavaScript strict warning: warning\n" | grep -v "JavaScript strict warning"
The output is:
Not a warning
However, when I filter the running output, lines with JavaScript strict warning
still come through. I believe that it's happening because the original command is spawning another process. Is there a way to keep filtering the output of the new process?
1the output you see may be stdout and stderr, but a pipe only passes on stdout. – MaQleod – 2014-03-12T21:40:10.990
@MaQleod is there a way to know if it's stderr? Is there a way to pass stderr to another pipe? – nathancahill – 2014-03-13T01:10:56.847
Actually, just figured it out. I added
3>&1 1>&2 2>&3
before the pipe, and everything works. Thanks for the correct diagnosis! If you add an answer I'll accept it. – nathancahill – 2014-03-13T01:17:17.700