As pointed out by Kernighan and Pike in their classic book, The UNIX
, there are a number of
principles that distinguish the UNIX environment.
One key concept is that programs are tools.
And like all good tools, they should be specific in function, but usable for
many different purposes.
In order for programs to become general-purpose tools, they must be
This means three things:
Within limits, the output of any program
should be usable as the input to another.
All of the information needed by a program
should either be contained in the data stream passed
to it or specified on the command line.
A program should not prompt for input or do unnecessary
formatting of output. In most cases, this means that UNIX
programs work with plain text files that don't contain "non-printable"
or "control" characters.
If no arguments are given, a program
should read the standard input (usually the terminal
keyboard) and write the standard output (usually
the terminal screen).
Programs that can be used in this way are often called filters
One of the most important consequences of
these guidelines is that programs can be strung together in "pipelines" in
which the output of one
program is used as the input of another.
A vertical bar (
) represents the
it means "take the
output of the program on the left and feed it into the program on the
For example, you can pipe the output of a search program
to another program that sorts the output, and then
pipe the result to the printer program or
redirect it to a file (13.1