Just trying to redirect stout to stderr. But I'm a little confused about these two commands.
echo test 2>/dev/null 1>&2
echo test 1>&2 2>/dev/null
I don't understand why the second one doesn't work properly.
Just trying to redirect stout to stderr. But I'm a little confused about these two commands.
echo test 2>/dev/null 1>&2
echo test 1>&2 2>/dev/null
I don't understand why the second one doesn't work properly.
>/dev/null 2>&1– Kusalananda Oct 10 '19 at 14:59echo test 1>&2 2>/dev/nullworking a little likeecho test 1>&2;echo test 2>/dev/null– bob dylan Oct 10 '19 at 15:012>/dev/null 1>&2iserr:=/dev/null; out:=err, and1>&2 2>/dev/nullisout:=err; err:=/dev/null. After the 1st, bothoutanderrwill be/dev/null, and after the 2nd,errwill be/dev/null, butoutwill be whatevererrwas before the operation (eg. a handle to your tty) – Oct 10 '19 at 16:54echo test 1>&2;echo test 2>/dev/nullis the same asecho test >&2; echo test, and unlike your 1st example (which does not print anything at all), will printtesttwice, once to stdout and once to stderr ;-) – Oct 10 '19 at 16:59