Review your favorite Linux distribution.
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 11-02-2005, 07:56 AM   #1
Senior Member
Registered: Sep 2005
Location: Out
Posts: 3,307

Rep: Reputation: 57
Bash redirection and subshells


I have a script which works fine that does something like:

function func () { 
   echo "glop"

echo "blah" 
echo "blih"
Now I want all the echos (moreover, all the stdout) to go to a file.

Which line do I have to add at the beginning of my script?
I don't want to modify all the script and don't want the script to be called by another script.

I thought about something like
but I think it does not work properly

Old 11-02-2005, 10:00 AM   #2
LQ Newbie
Registered: Oct 2005
Location: Netherlands
Posts: 21

Rep: Reputation: 15
try : exec >file
or all STDERR to a file : exec 2>file

Greets, Frank
Old 11-03-2005, 06:13 AM   #3
Senior Member
Registered: Sep 2005
Location: Out
Posts: 3,307

Original Poster
Rep: Reputation: 57



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 scripting I/O redirection error blinux1 Programming 13 03-18-2008 08:21 PM
Bash redirection being taken literally by programs R00ts Programming 13 05-26-2005 12:46 AM
bash subshells have trouble with && or || on next line dfloer Linux - General 6 12-28-2004 03:50 PM
bash output redirection: debian vs freebsd kenners Programming 2 10-07-2004 04:56 PM
BASH scripting: confused about redirection & file descriptors funkymunky Programming 1 06-07-2004 07:47 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:27 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