Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm doing some stream processing of some quite substantial files-- I was wondering if there was a way to split stdout in order to pipe to multiple programs. What I'd like to do is something like this:

bzcat some_huge_file.bz2 | (wc > wordcount, char_stats > character_statistics) 

I could write this glue in something like perl or python, but it seems like there ought to be a way to do this.

Google brings me to tpipe, but I can't find any copy of tpipe or sources (nothing local on OS X 10.8).

share|improve this question
3  
Found it- I don't have enough rep to post the answer outside a comment: The answer is tee and "process substitution". bzcat some_huge_file.bz2 | tee >(wc > wordcount) | char_stats > character_statistics – Matthew G. Dec 21 '12 at 17:58
    
I hope you will be able to post your answer 48 hours after posting your question, without rep issues. – pnuts Dec 21 '12 at 18:41
up vote 3 down vote accepted

Converting the poster's comment into a formal answer:

The answer is tee and "process substitution".

Example

bzcat some_huge_file.bz2 | tee >(wc > wordcount) | char_stats > character_statistics
share|improve this answer
    
It does however seem, that at least on OS X Lion, this results in some gently unexpected results-- Specifically, from what I've seen, it appears that the output of the process-substituted command (wc above) gets mixed with the input into the last command there (char_stats above) – Matthew G. Jan 9 '13 at 20:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .