5 ms·
Speaking of pipes, what would be a good way to branch pipes for some work and then join them back again in order? Running: ls | pee "./cruncher" "./muncher"
by yason 13y ago
Speaking of pipes, what would be a good way to branch pipes for some work and then join them back again in order? Running:
ls | pee "./cruncher" "./muncher"
will produce output from both ./cruncher and ./muncher in a mixed order. But often it would be more useful to synchronize the output so that all of ./cruncher output comes first and then ./muncher output.
You could redirect ./cruncher and ./muncher output to individual named pipes and then pipe a 'cat cruncherpipe muncherpipe' to follow that:
mkfifo cout mout
ls | pee "./cruncher >cout" "./muncher >mout" | cat cout mout
But that requires the manual precreation of the named pipes which isn't very clean. Using <(./cruncher) on the command line would automatically create an output pipe but doesn't allow redirecting the pipeline to each of the subcommands.
Any brilliant ideas?
- anonymous 13y agoYou need to buffer the input in any case, why not just LS=$(ls) ./cruncher <<END $LS END ./muncher <<END $LS END