In Ksh for redirecting i/o from a command away from standard output/error I do , [ where command is any command that produces output/error ]
command 2>filename
command 2>/dev/null
or
command &>filename
command &>/dev/null
In bash , often I see code like
command >&/dev/null
what does that additional &
signify, when the same can be get done by using
command> /dev/null
I know I am missing something fine, but glad to learn.
EDIT: I knew what 2>&1 is, which the so called duplicate question asks , I was told that 1 indicates a file descriptor and hence we need an & to refer that. I was puzzled to see & before the name of the file. Hence this question.
>&
syntax it had to be in that order because the parser wasn't as complicated andls &> junk.dat
was semantically equivalent tols & ; cat /dev/null > junk.dat
. For the benefit of a reader of a script, I'd still use>&
to lessen the ambiguity, but I'm pretty old skool. – msw Sep 25 '13 at 16:29