LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
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.

Notices

Reply
 
Search this Thread
Old 12-19-2003, 05:35 AM   #1
davee
Member
 
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

Dave...
 
Old 12-19-2003, 06:01 AM   #2
iainr
Member
 
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"
} >> $OUTFILE

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


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 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 10:00 AM
"Input/output error" on files at end of CD mfeat Linux - Software 2 11-23-2005 03:01 PM
Oracle 10g says "end of file" cyclic redundancy error mmjulian Linux - Software 2 05-22-2004 03:57 AM
"Premature end of script headers" bugging me ulto Programming 1 04-15-2004 07:38 PM
"No new line at end of file" Misel Programming 2 12-05-2003 01:55 PM


All times are GMT -5. The time now is 06:40 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration