I have two programs foo.sh
and bar.sh
both of which contain infite loops, produce continuous Output and should run in parallel. I would like to pipe the output of both those programs to a third program consumer
.
Initially I only had foo.sh
running and the piping was easy via
./foo.sh | ./consumer
But now I would like to add bar.sh
to also send its output to consumer
.
I have tried the things suggested in those answers (Answer 1, Answer 2) but they only seem to work for programs where one ends and the next gets started after the first one ends. I need them both to run in parallel.
This does not work, as it only pipes the output of foo.sh
and never starts bar.sh
:
( ./foo.sh ; ./bar.sh ) | ./consumer
This lucky guess gave me a syntax error:
( ./foo.sh & ; ./bar.sh & ) | ./consumer
{ command1 & command2; } | ...
not work for you? – Michael Homer Aug 17 '18 at 10:10command1
runs in the background andcommand2
starts shortly after. Try{ yes y & yes n ; } | cat
and see. You may need to provide your actual commands for someone to help you. – Michael Homer Aug 17 '18 at 10:19