LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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, 04: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, 05: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



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

LinuxQuestions.org > Forums > Linux Forums > Linux - General

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