Always redirect error to /dev/null

command lineio-redirection

I know I can redirect the error messages from a command to /dev/null using the following syntax:

command arg1 arg2 2>/dev/null

But is there a way to do this by default so that the error messages always go to /dev/null, unless I specify otherwise?

Best Answer

Lots of programs send output to stderr that isn't actually indicative of errors. For example, in some programs it is used to display information that would otherwise affect the output of the program (which is designed to be piped into another program). You can, however, do this:

exec 2>/dev/null

I wouldn't recommend doing this outside of a script.