3

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).

1
  • 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, 2012 at 17:58

1 Answer 1

3

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
1
  • 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, 2013 at 20:13

You must log in to answer this question.

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