Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I would like to pipe an output of to two separate commands <2,3> in bash. What is the best way of doing this? At the moment, I have following script:

command source > output
command2 output &
command3 output &

The output file is ~100G and a suboptimal way would be to pipe to commands 2 and 3 separately. I would think it is possible to do even more efficiently.

share|improve this question
    
Found out that tee is a possible way. Is this the way for the particular task? –  dr_dom Feb 25 '13 at 19:35
add comment

1 Answer

up vote 4 down vote accepted

In bash: command source | tee >(command2) >(command3)

From this stackoverflow question. I haven't tried this with ginormous outputs.

share|improve this answer
    
This command won't work unfortunately as "tee" dumps a copy of the output to a file, and another to stdout. (And yes, I tried it just to make sure this did not work as posed above) –  davidgo Feb 25 '13 at 21:19
1  
tee can take multiple files as arguments (which is how the two process substitutions appear to tee). You can redirect tee's standard output to /dev/null as well. –  chepner Feb 25 '13 at 21:25
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.