Basic Linux Tutorial
Computer Tutorial

Linux piping



Piping

A pipe is a form of redirection that is used in Linux and other Unix-like operating systems to send the output of one program to another program for further processing.
It shows another powerful feature of the UNIX shell, using the output of one command as input of another command. We call this process piping due to its similarity to the real-world use of a pipe. At the command line, both of the processes (commands) are connected using the vertical bar symbol "|". This symbol is often called a pipe symbol. When two commands are connected through a pipe, the first command sends its output to the pipe instead of sending it to the terminal screen. The second command reads its input from the pipe rather than from the keyboard. Both of the commands still send error messages to the terminal screen,

Piping

The first command takes input from the keyboard (stdin), and the second command sends its output to the terminal screen (stdout). If the second command needs input data but nothing is available in the pipe, it just waits for the first command to send something into the pipe. Pipes are often used to filter, modify, or manipulate data output of one command. Multiple levels of pipes can be used in one command line. Similarly, pipes can also be used in combination with I/O redirection symbols.