Pipe data between programs
In Linux, you can make one command’s output the standard input of another command. This process is called piping and it is done using the pipe symbol (|). Piping lets you have one command work on some data and then have the next command deal with the results.
Here is an example. We can use the ps -A command to list all process on the system:
We can then pipe the output of the ps command to the sort command. This results in the following sorted output:
Note that we have used the -k 4 option to sort by the executable name (the fourth field).
We can pipe together as many programs as we like. For example, we can pipe the output of the ps -A | sort -k 4 command to the tail command to display only the last ten lines of the output: