I can pipe two commands into a single child like so (Edit: actually you can't do it like this, see sarnold answers):
(echo "1.1 2.2 3.3") && (echo "4.4 5.5 6.6") | cat
which outputs
1.1 2.2 3.3
4.4 5.5 6.6
I want to do something similar with the output of tar. Currently I'm analysing data stored in a single tar files like so:
tar -x --to-command MySerialiser -f MyData1.tar.xz | MyAnalyser
where MySerialiser
preprocesses the data in a form ready for MyAnalyser
to read.
I now want to pipe the output of two tar files to MyAnalyser
.
I tried the following but output arrives on the terminal.
(tar -x --to-command MySerialiser -f MyData1.tar.xz) && (tar -x --to-command MySerialiser -f MyData2.tar.xz) | MyAnalyser
Can I do this with shell? or do I need to repackage my tar files?
You're doing it wrong (even for the first snippet).
{ tar -x --to-command MySerialiser -f MyData1.tar.xz && tar -x --to-command MySerialiser -f MyData2.tar.xz ; } | MyAnalyser