Reese Knowledgebase

Redirecting standard output and standard error

View Kristian Reese's profile on LinkedIn


If you like this article, please +1 or Recommend via FB with the provided buttons above:

Article ID: 18
by: Reese K.
Posted: 31 May, 2011
Last updated: 06 Nov, 2015
Views: 2261

Redirecting standard output and standard error

  • 2>/dev/null
  • >/dev/null 2>&1
  • 2>&1

The first specifies that all error messages should be sent to /dev/null

The second says to 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.

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

2 represents standard error and 1 standard output

This article was:   Helpful | Not Helpful
Also listed in
folder UNIX -> Linux
folder UNIX -> Solaris

Prev   Next
Search for largest files in a file system     Job Control in Unix

Showing: 1-1 of 1  
Comments
Anonymous | 10 Sep, 2013 11:21 AM
cmd &> /dev/null

also works to redirect both stdout and stderr.
Prev   Next
Search for largest files in a file system     Job Control in Unix

RSS