Search This Blog

Monday, January 16, 2012

"someCommand > /dev/null 2>&1" means

someCommand > /dev/null 2>&1

When I saw it, I don't understand what it means since I am not good at shell script.  Today, I searched online and got the answer from the following link:

http://www.xaprb.com/blog/2006/06/06/what-does-devnull-21-mean/

Below is my summary from the above blog:

Greater than (>) is for redirect, and the number 1 stands for STDOUT and 2 for STDERR, and 0 for STDIN.  By default, if no number provided, it is for STDOUT (number 1).  So the above script means STDOUT is redirected to /dev/null (called bit-bucket), and STDERR then is redirected to STDOUT which in turn is redirected to /dev/null.  It means both STDERR and STDOUT are redirected to /dev/null eventually.




No comments:

Post a Comment