LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Bash redirection and subshells (https://www.linuxquestions.org/questions/programming-9/bash-redirection-and-subshells-379244/)

nx5000 11-02-2005 07:56 AM

Bash redirection and subshells
 
Hi,

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


Code:


#!/bin/bash
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
Code:

1>outfile
but I think it does not work properly

Thanks

fvgestel 11-02-2005 10:00 AM

try : exec >file
or all STDERR to a file : exec 2>file

Greets, Frank

nx5000 11-03-2005 06:13 AM

Perfect,

Thanks


All times are GMT -5. The time now is 05:44 AM.