LinuxHelps.com

A blog for Linux Lovers.

8
Mar 2009
Define “/dev/null 2>&1″
Posted in Linux Helps by sibu at 5:35 am |

some_prog > /dev/null 2>&1

2 = standard error
1 = standard outout

The first part

“> /dev/null” means send standard output to the ‘bit bucket” or in other words, throw it away.

Second part

2> redirects STDERR to the specified file.

& only means to run the process in the background if it appears at the end of the line. 2>&1 redirects STDERR to STDOUT. Since in this case, STDOUT is being redirected to /dev/null,

2>&1 causes both STDERR and STDOUT to /dev/null.


You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

Leave a Reply