Suppressing Output from a Linux Command

After executing a Linux command have you ever wanted to suppress all of the output? I have and I finally found the answer. Turns out the answer is pretty straightforward.

Here is a typical example. I execute gedit and send the output to the bit bucket.

gedit > /dev/null

The command sends standard output to the null device. However, any output that would be sent to standard error still appears in the terminal window.

To turn off standard error, you can pass a modifier to the expression. Here is the list of options.

  • > /dev/null redirects stout to the null device
  • 1> /dev/null same result as the previous command
  • 2> /dev/null redirects sterr to the null device
  • &> /dev/null redirects sterr and stout to the null device

So to prevent any output in the terminal window the following command would be used:

gedit &> /dev/null

So to start the command as a background process would be:

gedit &> /dev/null &

And finally, to execute a command in the background without making it a child process of the terminal use this.

(gedit &> /dev/null &)

This command will launch gedit in its own process and prevent any output from appearing in the terminal.