Traduisez - Übersetzen - Traduzca - Traduza - Tradurre - Translate

Re: Redirecting the !#$%^& output from STDIN and STDERR to a file...

Brian Edmonds (brian@gweep.bc.ca)
07 Aug 1998 08:45:17 -0700

Please do not Cc me on replies, I get the list just fine thanks. If
your mail program wants to Cc me, fix it; if it insists, find a new mail
program.

Turbo Fredriksson <turbo@tripnet.se> writes:
>> It has to be the other way around (first redirect stdout, then stderr
>> to stdout): 'whatever_binary > file_for_output 2>&1'
> Ahh... But when you do 'whatever_binary 2>&1 | tee file_for_output',
> it works, so I just imagined to put a '>' instead of the '| tee'...

It works for the pipe because you're not actually redirecting standard
out, you're just fitting it into a pipeline. What happens in the two
cases with redirection is:

1. >blah 2&>1 : redirect stdout to blah, redirect stderr to wherever
stdout is going; result stdout and stderr to blah.
2. 2&>1 >blah : redirect stderr to wherever stdout is going, redirect
stdout to blah; result stdout to blah, stderr to wherever stdout
*was* going.

Hope that made sense. :)

Brian.