Unix: How to redirect STDOUT and STDERR to /dev/null

Linux/Unix FAQ: How do I redirect STDOUT and STDERR to /dev/null?

To redirect both STDOUT and STDERR to /dev/null, use this syntax:

$ my_command > /dev/null 2>&1

With that syntax, when my_command is run, its STDOUT output is sent to /dev/null (the “bit bucket”), and then STDERR is told to go to the same place as STDOUT. This syntax can be used to redirect command output to any location, but we commonly send it to /dev/null when we don’t care about either type of output.