O'Reilly logo

Linux and Unix Shell Programming by David Tansley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

5.6. Standard input, output and errors

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.

Files File descriptor
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.

5.6.1. Standard input

Standard input is file descriptor ‘0’. This is where input goes into commands, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required