A common question that comes up from people new to bash scripting is: “How do I redirect standard error to standard out?” There are a few ways to write this but the clearest way in my opinion is “command 2>&1″. File descriptor 2 is standard error, and 1 is standard out. So “2>&1″ reads in the form of the question: “File descriptor 2 is being redirected to file descriptor 1.”
However, I think that question itself causes confusion. I don’t think the phrase should be “redirecting standard error to standard out.” Rather, you are redirecting standard error to where standard out points to. You can also think “the file descriptors describe the files they point too.” To see this behavior, you can run ‘xclock 1> ~/scrap/foo 2>&1 ‘. What this does is redirect standard error to where standard out points to, and then redirects standard output to ‘~/scrap/foo’. If you run the following: ‘ls -l /proc/pid_of_xclock/fd’, you will see the above described behavior in action.