On Fri, Mar 14, 2003, Tzafrir Cohen wrote about "Re: pipe question":
> tee to a file
>..
> I also recall a "multi-cat" or "multi-pipe" file, but can't seem to find
> it anywhere.
> 
> Also: can this be done using a more complicated redirection in a
> standard shell?

With Zsh (my favorite shell, and works on every conceivable system including
Linux and Windows), you could do, with the "multios" feature:

        setopt multios

        ls >file | grep a       # saves ls output on file, and also greps "a"
        ls >file1 >file2        # saves ls output to both file1 and file2

This might look like a silly way to save an extra "tee" run, but an external
"tee" program sometimes causes annoying side-effects that ZSH's multios solves
(not to mention it being more convenient). For example, if you do

        ls | tee file1 >file2

The exit code of that pipeline is that of tee (i.e., normally a success) and
you don't know whether or not ls succeeded. With multios, you get to know
the ls exit code:
        ls >file1 >file2

By the way, the "multios" option is not enabled by default, perhaps because
it's a bit dangerous - if you do
        echo hi >*
You'll overwrite every file in the current directory with "hi" :(

-- 
Nadav Har'El                        |     Friday, Mar 14 2003, 10 Adar II 5763
[EMAIL PROTECTED]             |-----------------------------------------
Phone: +972-53-245868, ICQ 13349191 |A Nobel Peace Prize? I would KILL for one
http://nadav.harel.org.il           |of those.

=================================================================
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]

Reply via email to