
上QQ阅读APP看书,第一时间看更新
8.10 Working with Pipes in the Bash Shell
In addition to I/O redirection, the shell also allows output from one command to be piped directly as input to another command. A pipe operation is achieved by placing the ‘|’ character between two or more commands on a command-line. For example, to count the number of processes running on a system, the output from the ps command can be piped through to the wc command:
$ ps –ef | wc –l
There is no limit to the number of pipe operations that can be performed on a command-line. For example, to find the number of lines in a file which contain the name Smith:
$ cat namesfile | grep Smith | wc –l