I read from this answer about the distinguish between |
and ;
https://unix.stackexchange.com/a/159492/318084;
Consider two commands A and B. When you write
A | B
A and B are executed in parallel, and the standard output of A is sent as the standard input of B.
I am confused about the word parallel
I could understand the description from Pipeline (Unix) - Wikipedia
Unix-like computer operating systems, a pipeline is a sequence of processes chained together by their standard streams, so that the output of each process (stdout) feeds directly as input (stdin) to the next one.
Pipeline is passing output to next as input.
Nonetheless, the answer say "parallel", they are executing simultaneously instead of in sequence.
How this mechanism working?
I guess |
should spawn a subshell which get variable from A in parent-shell (export the variable) then the subshells are closed automatically when jobs are finished.