Redirecting stdout and stderr

How to redirect standard output and standard error

We’ve seen the numbers used in redirecting stdout and stderr. So what do they mean?

  • 1 represents standard output
  • 2 represents standard error

2>&1 indicates that the standard error (2) is redirected (>) to the same file descriptor (&1) that is pointed by standard output (1)


redirect standard output to /dev/null and redirect standard error to standard output (meaning all output to both standard output/error are redirected to /dev/null)

>/dev/null 2>&1


send all error messages to /dev/null