LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices


Reply
  Search this Thread
Old 11-02-2005, 07:56 AM   #1
nx5000
Senior Member
 
Registered: Sep 2005
Location: Out
Posts: 3,307

Rep: Reputation: 57
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
 
Old 11-02-2005, 10:00 AM   #2
fvgestel
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
nx5000
Senior Member
 
Registered: Sep 2005
Location: Out
Posts: 3,307

Original Poster
Rep: Reputation: 57
Perfect,

Thanks
 
  


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
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

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:27 PM.

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