When using commands in the shell, the shell associates each process with an open file, and references these open files by using numbers called file descriptors. As numbers are not very easy to remember, the shell gives them (file) names as well.
Here are the file descriptors and their more common names.
|Input file – standard input||0|
|Output file – standard output||1|
|Error output file – standard error||2|
There are actually 12 file descriptors, but as can be seen from the above table, 0,1, and 2 are reserved for the ‘standard’ input, output and errors. You are free to use descriptors 3 to 9.
Standard input is file descriptor ‘0’. This is where input goes into commands, ...