UNIX uses the concept of a pipe
to connect the standard output of
one program directly into the standard input of another program.
This is specified by separating the two commands with the pipe
operator, the vertical bar ( ). The general format is:
command1For example, to sort the output of the who command:command2
...
whosort
Of course, each command can have options and arguments.
The tee command can be used to send output to a file as well as to another command.
whoThis is the same as the previous example except that a file named whoout is created containing the original who output. The sorted output goes to standard output, the terminal screen.tee whoout
sort
It is possible to set up multiple pipes. Commands that appear in pipe statements may include all the usual options and file designations.
ls -l | lpThis command pipes the output of the ls command to the printer via the lp command.