LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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, 11: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, 12:03 PM   #2
jim mcnamara
Member
 
Registered: May 2002
Posts: 964

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

Rep: Reputation: 90
blah blah >> mylog 2>> mylog
 
Old 03-11-2005, 03:52 PM   #4
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,604

Rep: Reputation: 884Reputation: 884Reputation: 884Reputation: 884Reputation: 884Reputation: 884Reputation: 884
Code:
 >> file.log 2>&1
 
Old 03-12-2005, 08: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 09:35 PM
Redirecting error messages to stderr and file in Bash lowpro2k3 Programming 1 04-14-2005 07:47 PM
Reopen the stdout and stderr rahul_kulkarni Programming 3 02-21-2005 07:55 AM
redirecting stderr nodger Programming 2 03-11-2004 11:58 AM
Redirecting stdout from tar to a text file. heatlill Programming 2 01-22-2002 11:27 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:23 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration