10.23
The pipe is the vertical line above your enter key. It looks like this without the quotes: “|”. Using the pipe character in the Linux shell allows you to string commands together, performing another command on the output from the first. This is a list of 10 things you can do with the pipe that will help you master the command line.
Remember, these commands don’t have to be used as given in the list below, look up the man pages for additional options and arguments. Also, don’t forget that you can string piped commands to use more than one. Stringing piped commands are very powerful when combined.
1. Grep
Grep is one of the most common commands used with the pipe. It allows you to quickly search through the output of another command. For an example, look at the following code. Grep can also take regular expressions as arguments.
ps ux | grep /usr
This command will print every line of the list of processes with “/usr” in it.
2. Head
Head simply displays the first 10 lines of whatever you piped into it. Here’s your example:
ls / -l | head
This example shows the first 10 lines of the directory listing.
Read More >>