LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices



Reply
 
Search this Thread
Old 12-07-2006, 05:22 PM   #1
jantman
Member
 
Registered: Nov 2005
Location: New Jersey, USA
Distribution: SuSE
Posts: 492

Rep: Reputation: 31
Shell script - stdout & stderr to terminal and file


Hello,

How do I go about adding to a shell script so that its' STDOUT and STDERR will both be seen on screen (as normal) and ALSO sent to a file?

Thanks,
Jason
 
Old 12-07-2006, 05:34 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,415

Rep: Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968
that'll be the "tee" command.

echo test | tee blah

should echo the word "test" but also write to the file called "blah". note that that will by default only cover stdout, not stderr too, so you'd need to redirect stderr to stdout beforehand:

echo 2>&1 test | tee blah

otherwise the blah file would only include stdout, not the error stream.

Last edited by acid_kewpie; 12-07-2006 at 05:36 PM.
 
  


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 stdout to /dev/null and stderr to stdout? Thinking Programming 1 05-18-2006 03:36 AM
Any way to split up STDOUT and STDERR, and then recombine in the right order? Lumberg Linux - Software 10 04-18-2006 09:38 AM
redirecting stdout and stderr to a file Avatar33 Programming 4 03-12-2005 08:55 AM
Reopen the stdout and stderr rahul_kulkarni Programming 3 02-21-2005 07:55 AM
shell short question(stdout, stderr) blackzone Programming 4 11-11-2004 10:01 AM


All times are GMT -5. The time now is 02:44 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration