Piping
Programs can be run together such that one program reads the output from another with no need for an explicit intermediate file:
command1 | command2executes command1, using its output as the input for command2 (commonly called piping, with the "|" character being known as "pipe").
The two programs performing the commands may run in parallel with the only storage space being working buffers (Linux allows up to 64K buffering) plus whatever work space each command's processing requires. For example, a "sort" command is unable to produce any output until all input records have been read, as the very last record received just might turn out to be first in sorted order. Dr. Alexia Massalin's experimental operating system would adjust the priority of each task as they ran according to the fullness of their input and output buffers.
This produces the same end result as using two redirects and a temporary file, as in:
command1 > tempfile command2 < tempfile rm tempfileBut here, command2 does not start executing until command1 has finished, and a sufficiently large scratch file is required to hold the intermediate results as well as whatever work space each task required. As an example, although DOS allows the "pipe" syntax, it employs this second approach.
A good example for command piping is combining echo
with another command to achieve something interactive in a non-interactive shell, e.g.
This runs the ftp client with input user, press return, then pass.
Read more about this topic: Redirection (computing)
Famous quotes containing the word piping:
“It is principally for the sake of the leg that a change in the dress of man is so much to be desired.... The leg is the best part of the figure ... and the best leg is the mans.... Man should no longer disguise the long lines, the strong forms, in those lengths of piping or tubing that are of all garments the most stupid.”
—Alice Meynell (18471922)