Each line that the shell reads from the standard input or a script is called a pipeline; it contains one or more commands separated by zero or more pipe characters (|). For each pipeline it reads, the shell breaks it up into commands, sets up the I/O for the pipeline, then does the following for each command (Figure 7-1):
- Splits the command into tokens that are separated by the fixed set of metacharacters: SPACE, TAB, NEWLINE, ;, (, ), <, >, |, and &. Types of tokens include words, keywords, I/O redirectors, and semicolons.
After the shell breaks a pipeline into commands separated by
|, why is
|still listed as a metacharacter which separate tokens in each command? Can
|appear in each command?
The Bash Manual says that when a bash shell runs a pipeline, it forks a subshell to run each command in a pipeline.
For each command in a pipeline, which shell "does the following for each command": the subshell forked for the command, or the original shell?