bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: file descriptors, redirection and other animals....


From: Stephane CHAZELAS
Subject: Re: file descriptors, redirection and other animals....
Date: Tue, 10 Mar 2009 12:01:14 +0000 (UTC)
User-agent: slrn/pre1.0.0-2 (Linux)

2009-03-10, 01:54(-07), simonm:
[...]
> cat very_large_text_file | a | long | and | complex | chain | of |
> pipes | tee <(command_one) <(command_two) 1>/dev/null
>
> So, I want to apply command_one and command_two to the whole output of
> the resulting text stream coming from "pipes".
>
> Is there another way to do it, other than using tee, (very large) temp
> files or (very large) variables?
[...]

{
< very_large_text_file | a | long | and | complex | chain | of |
 pipes | tee >(command_one >&3) | command_two
} 3>&1

Note that command_one and command_two will run in parallel and
in bash or ksh93 (contrary to zsh), the shell will not wait for
command_one, so it may still be running when that pipe line
returns (though probably not for long if it stops after it see
eof on its stdin).

With zsh:

... of | pipes > >(command_one) > >(command_two)

(zsh performs the tee internally here, that's the MUTL_IOS
option).

~$ setopt multios
~$ echo foo > >(tr f F) > >(tr o O)
Foo
fOO

-- 
Stéphane


reply via email to

[Prev in Thread] Current Thread [Next in Thread]