cat food 2>&1 >filecat: can't open food $
cat food >file 2>&1$
On the first command line, the shell sees
That means "make the standard error (file descriptor 2) go to the same
place as the standard output (fd1) is going."
There's no effect because both fd2 and fd1 are already going to the terminal.
>file redirects fd1 (stdout) to
But fd2 (stderr) is still going to the terminal.
On the second command line, the shell sees
>file first and
redirects stdout to
2>&1 sends fd2 (stderr) to the same place fd1 is
going - that's to the file.
And that's what you want.
has much more about the