When we’re scripting or running a command on Linux we sometimes don’t want any output from the command. This output may be the success message from the command on stdout (standard output) or an error message on stderr (standard error).
The usual way to do this is with the classic:
$ <COMMAND> 2>&1 >/dev/null
This redirects stderr
into stdout
and then sends stdout
to the bitbucket /dev/null
.
Instead, we can use the following:
$ <COMMAND> &>/dev/null
The &>
redirects both stderr
and stdout
to /dev/null
.
It’s not much of a saving but it will make your scripts and oneliners a little cleaner.