I am having some difficulty understanding the construct prog > file 2>&1. I have read that it means Send stdout and stderr to file. But my question is how?I understand that prog > file basically sends stdout to file. I also understand that prog 2>&1 means that the stderr should be sent to stdout. But I am not able to connect the dots for  prog > file 2>&1. Can experts here help me decode this.
Decoding prog > file 2>&1
shell;io redirection;stdout;stdin
You just have to read it left to right:> file --> redirect all thing from stdout to file.(You can imagine you have a link, point-to-point from stdout tofile)2>&1 --> redirect all thing from stderr to stdout, which is now pointed to file.So conclusion:stderr --> stdout --> fileYou can see a good reference here.