I know how to combine the result of different command
paste -t',' <(commanda) <(commandb)
I know pipe same input to different command
cat myfile | tee >(commanda) >(commandb)
Now how to combine these command? So that I can do
cat myfile | tee >(commanda) >(commandb) | paste -t',' resulta resultb
Say I have a file
myfile:
1
2
3
4
I want to make a new file
1 4 2
2 3 4
3 2 6
4 1 8
I used
cat myfile | tee >(tac) >(awk '{print $1*2}') | paste
would gives me result vertically, where I really want paste them in horizontal order.
Best Answer
When you tee to multiple process substitutions, you're not guaranteed to get the output in any particular order, so you'd better stick with
Assuming
cat myfile
stands for some expensive pipeline, I think you'll have to store the output, either in a file or a variable:Using your example:
Another thought: FIFOs, and a single pipeline