-   Programming (
-   -   redirecting stdout and stderr to a file (

Avatar33 03-11-2005 10:06 AM

redirecting stdout and stderr to a file

I'm trying to write a script and at the same time log all errors to a file.
I've noticed that in configure scripts they use this:

exec 5>config.log
echo 'stuff to log' >&5

but this only logs stdout to config.log. I want to append both stdout and stderr.


&> file.log
redirects both stderr and stdout but overwrites the files old contents.
Again this is not what I want.

So how do I go about redirecting both stdout and stderr to a file but appending to the files last contents?


jim mcnamara 03-11-2005 11:03 AM


2>&1 | tee -a file.log

eantoranz 03-11-2005 01:13 PM

blah blah >> mylog 2>> mylog

keefaz 03-11-2005 02:52 PM


>> file.log 2>&1

Avatar33 03-12-2005 07:55 AM

Thanks, much appreciated.

All times are GMT -5. The time now is 01:48 PM.