Help answer threads with 0 replies.
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 09-11-2008, 06:28 AM   #1
Registered: Sep 2003
Location: Melbourne, Australia
Distribution: NetBSD 3.0.1, Slackware 10.1
Posts: 394

Rep: Reputation: 30
Bash Scripting: Redirect output of entire script to file & screen

Hi All,

Trying to get my head around this one.

How would I redirect stdout and stderr of an entire bash script to a file, but also leaving the output to the screen?

I've tried various combination of exec and tee, and I can't get anything to work =/

Any help is much appreciated.

Old 09-11-2008, 06:31 AM   #2
Senior Member
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 63
First copy stderr to stdout, then use tee to copy stdout to a file:
Code: 2>&1 |tee out.log


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
BASH: How to Redirect Output to File, AND Still Have it on Screen edwin11 Linux - Software 25 07-02-2012 07:12 PM
Shell scripting: How to redirect output from within the script itself? Arodef Linux - General 4 05-23-2006 08:30 PM
redirect screen output to file timbuck Linux - Software 5 12-09-2005 07:57 PM
Is there a way in Linux/Unix bash to turn off output or redirect to a file jimwelc Linux - Newbie 6 01-06-2005 04:56 AM
Can I redirect script output to a file without ">> $LOGFILE" at the end of each line davee Linux - General 1 12-19-2003 06:01 AM

All times are GMT -5. The time now is 06:45 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration