Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


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

Rep: Reputation: 15
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?

Old 03-11-2005, 12:03 PM   #2
jim mcnamara
Registered: May 2002
Posts: 964

Rep: Reputation: 34
2>&1 | tee -a file.log
Old 03-11-2005, 02:13 PM   #3
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, 03:52 PM   #4
Senior Member
Registered: Mar 2004
Distribution: Slackware
Posts: 4,617

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

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


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

All times are GMT -5. The time now is 10:17 AM.

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