Bash One-Liners Explained, Part III: All about redirections
Working with redirections in bash is really easy once you realize that it’s all about manipulating file descriptors. When bash starts it opens the three standard file descriptors: stdin (file descriptor 0), stdout (file descriptor 1), and stderr (file descriptor 2). You can open more file descriptors (such as 3, 4, 5, …), and you can close them. You can also copy file descriptors. And you can write to them and read from them. ...