You are not logged in.

#1 2010-04-25 14:06:29

eirika
Member
From: New York
Registered: 2009-09-14
Posts: 65

Sending output to 2 pipelines in shell script?

I have a large file to process using grep, however the same output of grep
will be used by 2 different programs. Processing the large input file twice
will be a waste of time. Is there a way to duplicate the output data and send it
to 2 separate pipelines?

As a resolution saving the grep output to a temporary file and reading the file twice
will do the job. But I would like to know if there is a possibility to avoid using
tmp files.

Offline

#2 2010-04-25 14:15:01

mksoft
Member
Registered: 2008-07-03
Posts: 9

Re: Sending output to 2 pipelines in shell script?

The tee command will help you with it, google will have some examples, here's one:
http://linux.byexamples.com/archives/14 … processes/

Offline

#3 2010-04-25 14:23:18

eirika
Member
From: New York
Registered: 2009-09-14
Posts: 65

Re: Sending output to 2 pipelines in shell script?

mksoft wrote:

The tee command will help you with it, google will have some examples, here's one:
http://linux.byexamples.com/archives/14 … processes/

That's wonderful smile
However process substitution is not part of the POSIX standard. I think that's why I didn't
see it in some of my scripting textbooks.

Offline

Board footer

Powered by FluxBB