When redirecting errors, note that the order of precedence is significant. For example, this command, issued in /var/spool
ls -l * 2 > /var/tmp/unaccessible-in-spool
will redirect output of the ls command to the file unaccessible-in-spool in /var/tmp . The command
ls -l * > /var/tmp/spoollist 2 >& 1
will direct both standard input and standard error to the file spoollist . The command
ls -l * 2 >& 1 > /var/tmp/spoollist
directs only the standard output to the destination file, because the standard error is copied to standard output before the standard output is redirected.
For convenience, errors are often redirected to /dev/null , if it is sure they will not be needed. Hundreds of examples can be found in the startup scripts for your system.
Bash allows for both standard output and standard error to be redirected to the file whose name is the result of the expansion of FILE with this construct:
&> FILE
This is the equivalent of > FILE 2>&1 , the construct used in the previous set of examples. It is also often combined with redirection to /dev/null , for instance when you just want a command to execute, no matter what output or errors it gives.

