Tugger the SLUGger!SLUG Mailing List Archives

Re: [SLUG] tee(1): Pipe fitting.


Visser, Martin SNO <Martin.Visser@xxxxxxxxxx> wrote:

> As an aside how does one do a "tee" to say two commands? For instance, in
> pseudo-shell

> ls | tee ( wc ) | (grep foobar | wc )

Here's one way (assuming you're not trying to list /tmp of course):

fifo=/tmp/fifo$$
mkfifo $fifo || exit
ls | tee $fifo | wc&
set -- "$(< $fifo grep foobar | wc)"
wait
rm $fifo
echo "$*"
-- 
Debian GNU/Linux 2.2 is out! ( http://www.debian.org/ )
Email:  Herbert Xu ~{PmV>HI~} <herbert@xxxxxxxxxxxxxxxxxxx>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt