Does >/dev/null 2>&1 and 2>&1 >/dev/null mean the same?
Hi.
They're not the same.
In the first case, standard output is directed to a file (in this case /dev/null), and then standard error is directed to the same place (&1, or /dev/null).
It's equivalent to
> /dev/null 2> /dev/null
In the second case, standard error is directed to where standard output is directed at the time (i.e. the screen), and then standard output is directed to somewhere else (/dev/null)
$ cat Test
echo stdout
echo stderr >&2
$ ./Test > /dev/null 2>&1
$
$ ./Test 2>&1 > /dev/null
stderr
Then basically ">/dev/null 2>&1" and "&> /dev/null" do the same job i guess??
&> /dev/null
Works only in Bash FWIK.
[root@wiki ~]# echo "1" &> /dev/null
[root@wiki ~]#
[root@wiki ~]# ech "1" &> /dev/null
[root@wiki ~]#
">/dev/null 2>&1" and "&> /dev/null" does the same job