Extract STDERR and redirect STDOUT to /dev/null with bash

I always keep forgetting this bash syntax redirection. This is because of my short memory and also because I do not use it often. In many cases we need to remove a STDERR from the command output and keep only STDOUT. On the other hand there are times that we want to see STDERR and remove STDOUT.  Here is how to do it:

$ BASH-COMMAND 2>&1 > /dev/null

Leave a Reply

You must be logged in to post a comment.