Using pipelines |
|
Suppose you want to take the output of some command, call it
first, and use that stream as the input of another
command called second. This can be done via
redirection:
yourname@yourcomputer<28>% first >temp
yourname@yourcomputer<29>% second <temp
The output of the first command is redirected to a
temporary file named temp, and then the input of the
second command is redirected from file temp.
We can do the same thing with a pipeline like this:
yourname@yourcomputer<30>% first | second
The pipe (|) symbol placed between two commands tells
Unix to take the output produced by the commands before the pipe symbol
and make that the input of the commands after the pipe symbol.