I am having a hard time understanding the difference between the order of 1>&2 and >. For example, I have
file and don't have fie. Then
diff fie file2 gives me error and I try redirecting the error message to stdout as follows:
$ diff fie file2 > out.log 2>&1 $ cat out.log diff: fie: No such file or directory
However, if I reverse the order as
$ diff fie file2 2>&1 > out2.log diff: fie: No such file or directory $ cat out2.log $
the output is different. Why is this? and if the STDERR and STDERR are merged by 2>&1, will the file descriptor 2 be empty? and can anyone point to a reference about >& and <& ? Thank you.