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?

  • 1
    the output you see may be stdout and stderr, but a pipe only passes on stdout. – MaQleod Mar 12 '14 at 21:40
  • @MaQleod is there a way to know if it's stderr? Is there a way to pass stderr to another pipe? – nathancahill Mar 13 '14 at 1:10
  • 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 Mar 13 '14 at 1:17

the output you see is likely stderr - a pipe only passes on stdout by default.

As you noted in your comment you can use redirects to adjust what gets passed on.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.