< Day Day Up > |
7.11. PipesA pipe takes the output from the command on the left-hand side of the pipe symbol and sends it to the input of the command on the right-hand side of the pipe symbol. A pipeline can consist of more than one pipe. The purpose of the next three commands is to count the number of people logged on (who), save the output of the command in a file (tmp), use the wc 僕 to count the number of lines in the tmp file (wc 僕), and then remove the tmp file (i.e., find the number of people logged on). See Figures 7.4 and 7.5 Example 7.41.1 $ who > tmp 2 $ wc 僕 tmp 4 tmp 3 $ rm tmp # Using a pipe saves disk space and time. 4 $ who | wc 僕 4 5 $ du . | sort 墨 | sed 墨 '$p' 72388 /home/jody/ellie Figure 7.4. The pipe.Figure 7.5. Multiple pipes (filter).EXPLANATION
|
< Day Day Up > |