Pipes
A shell pipeline or simply a pipeline refers to a construct where data is pushed from one command to another in an assembly line fashion. It is expressed as a series of commands separated by a pipe symbol |
. These pipes connect the stdout
of each command to the stdin
of the subsequent command. Internally, a pipe is a special memory FIFO (first in, first out) buffer provided by the OS.
The basic syntax of a pipeline is as follows:
command1 | command2
Any number of commands can be linked:
command1 | command2 | command3 | command4
Pipelines are analogous to assembly lines in a factory. Like an assembly line lets multiple workers simultaneously do one designated job repeatedly, ending up with a finished product, a pipeline lets a series of commands work on a stream of data, each doing one task, eventually leading to the desired output.
Pipelines ensure maximum throughput and optimal usage of computing power. The time taken for a pipeline task in most cases will...