September 21, 2007
The order matters
$ ls file-that-does-not-exist 2>&1 >/dev/null
ls: file-that-does-not-exist: No such file or directory
$ ls file-that-does-not-exist >/dev/null 2>&1
$
If you want both stderr and stdout to go to /dev/null then “>/dev/null 2>&1″, but if you want stdout to go to /dev/null and stderr to go to whereever stdout used to go to, then “2>&1 >/dev/null”.