Pipelines are a great way to string together a series of commands. This means that the output from the first command in the pipeline is used as the input for the second command in the pipeline. The output from the second command in the pipeline is used as the input to the third command in the pipeline, and so on, and so on.
The output from the last command in the pipeline is the only output that you will actually see displayed on the screen. You can tell BASH to create a pipeline by typing two or more commands separated by a vertical bar, or pipeline character (|). For example:
cat sample.text | grep "High" | wc -l
The above pipeline would take the output from the cat command (listing the contents of a file). and send them to the grep command. The grep command searches for each occurrence of the word High in it’s input. The grep command output would now consist of each line within the file that contained the word High. This output is now sent to the wc command where the wc command with the -l option prints the total number of lines contained in it’s input. Let’s pretend the contents of our sample.txt file are as follows:
Today's To-Do List: Low: Go buy eggs High: Return Late Movie High: Pay Rent Medium: Pick up dry cleaning
Now if we ran the above pipelined command on our sample.txt file, our output would be 2 – indicating that we have 2 things of high importance to do today.