Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


  Search this Thread
Old 12-19-2003, 04:35 AM   #1
Registered: Oct 2002
Location: Ayrshire, Scotland
Distribution: Suse(home) RHEL (Work)
Posts: 263

Rep: Reputation: 30
Can I redirect script output to a file without ">> $LOGFILE" at the end of each line

To stop me having to do...

export OUTFILE=/home/user/logs
echo "Start script" >> $OUTFILE
echo "Blah blah " >> $OUTFILE
run command -a -h >> $OUTFILE
do this and that >> $OUTFILE
echo "Stop Script" >> $OUTFILE

Old 12-19-2003, 05:01 AM   #2
Registered: Nov 2002
Location: England
Distribution: Ubuntu 9.04
Posts: 631

Rep: Reputation: 30
Two ways round this.

1. Put the chunk of code in curly brackets[code]{
echo "Start script"
echo "Blah blah "
run command -a -h
do this and that
echo "Stop Script"

2. Use the exec command to redirect output to the file automatically (I have to say I haven't done this with Linux/Bash so read the man page for this one).


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 On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to write a bash script to replace all "KH" to "K" in file ABC??? cqmyg5 Slackware 4 07-24-2007 09:00 AM
"Input/output error" on files at end of CD mfeat Linux - Software 2 11-23-2005 02:01 PM
Oracle 10g says "end of file" cyclic redundancy error mmjulian Linux - Software 2 05-22-2004 02:57 AM
"Premature end of script headers" bugging me ulto Programming 1 04-15-2004 06:38 PM
"No new line at end of file" Misel Programming 2 12-05-2003 12:55 PM > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 10:10 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
Open Source Consulting | Domain Registration