LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 03-11-2005, 10:06 AM   #1
Avatar33
Member
 
Registered: May 2003
Location: South Africa
Distribution: Ubuntu
Posts: 75

Rep: Reputation: 15
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
 
Old 03-11-2005, 11:03 AM   #2
jim mcnamara
Member
 
Registered: May 2002
Posts: 964

Rep: Reputation: 34
Code:
2>&1 | tee -a file.log
 
Old 03-11-2005, 01:13 PM   #3
eantoranz
Senior Member
 
Registered: Apr 2003
Location: Colombia
Distribution: Kubuntu, Debian, Knoppix
Posts: 1,982
Blog Entries: 1

Rep: Reputation: 83
blah blah >> mylog 2>> mylog
 
Old 03-11-2005, 02:52 PM   #4
keefaz
Senior Member
 
Registered: Mar 2004
Distribution: Slackware
Posts: 4,340

Rep: Reputation: 73
Code:
 >> file.log 2>&1
 
Old 03-12-2005, 07:55 AM   #5
Avatar33
Member
 
Registered: May 2003
Location: South Africa
Distribution: Ubuntu
Posts: 75

Original Poster
Rep: Reputation: 15
Thanks, much appreciated.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Redirecting to file and stdout Quantum0726 Programming 3 11-14-2005 08:35 PM
Redirecting error messages to stderr and file in Bash lowpro2k3 Programming 1 04-14-2005 06:47 PM
Reopen the stdout and stderr rahul_kulkarni Programming 3 02-21-2005 06:55 AM
redirecting stderr nodger Programming 2 03-11-2004 10:58 AM
Redirecting stdout from tar to a text file. heatlill Programming 2 01-22-2002 10:27 AM


All times are GMT -5. The time now is 03:15 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration