Normally, pipelines in Unix are used to connect two commands and use the output of the first command as the input of the second command. However, I recently come up with the idea (which may not be new, but I didn't find much Googling) of using pipeline to run several commands in parallel, like this:
command1 | command2
This will invoke
command1
and command2
in parallel **even if command2
does not read from standard input and command1
does not write to standard output**. A minimal example to illustrate this is (please run it in an interactive shell)
ls . -R 1>&2|ls . -R
My question is, are there any downsides to use pipeline to parallelize the execution of two commands in this way? Are there anything that I have missed in this idea?
Thank you very much in advance.
Asked by Weijun Zhou
(3548 rep)
Dec 8, 2017, 09:31 PM
Last activity: Jun 4, 2024, 02:50 AM
Last activity: Jun 4, 2024, 02:50 AM