Sometimes we may want to silence the errors in Bash or Zsh, such as when using find
and we don't want the "Permission denied" messages to clobber up the results. The 2> /dev/null
or 2>&-
can be added to the command
sudo find / -name opendiff 2> /dev/null
or
sudo find / -name opendiff 2>&-
The 2
above is the file descriptor for the standard error stderr
. /dev/null
is the "null device" (also called the bit bucket or black hole). The >&-
is to close the file descriptor, and 2>&-
is to close stderr
.
Top comments (0)