LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   redirecting stdout and stderr to a file (http://www.linuxquestions.org/questions/programming-9/redirecting-stdout-and-stderr-to-a-file-300413/)

Avatar33 03-11-2005 11:06 AM

redirecting stdout and stderr to a file
 
Hi

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:
Code:

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.

Code:

&> 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?

Thanks.
Avatar

jim mcnamara 03-11-2005 12:03 PM

Code:

2>&1 | tee -a file.log

eantoranz 03-11-2005 02:13 PM

blah blah >> mylog 2>> mylog

keefaz 03-11-2005 03:52 PM

Code:

>> file.log 2>&1

Avatar33 03-12-2005 08:55 AM

Thanks, much appreciated.


All times are GMT -5. The time now is 02:43 AM.