Re: [Linuxcommand-discuss] question about redirection
Brought to you by:
bshotts
From: William S. <bs...@pa...> - 2004-02-11 14:51:42
|
Yes, by all means you would want to use a variable instead. It would make your script easier to maintain. I would suggest that in keeping with convention, the name of the variable should have an uppercase name since it you are treating the variable as a constant. ||||| William Shotts, Jr. (bshotts AT panix DOT com) ||||| Be a Linux Commander! Follow me to http://linuxcommand.org On Wed, 11 Feb 2004, Bram Mertens wrote: > Hi > > I would like to use the following script to start evolution from now on > so the output would be logged. > > Can I replace the "/data/logs/evolution.log" with a variable? Right now > it looks quite ugly and reusing the script for other apps would involve > too much typing/a high risk of typos/not enough laziness :) > > --- script --- > #!/bin/bash > > echo "" >> /data/logs/evolution.log > echo "--- $(date +"%R %A, %B %-d, %Y") ---" >> /data/logs/evolution.log > evolution >> /data/logs/evolution.log 2>&1 > --- end --- > Can I replace it with something like: > --- script --- > #!/bin/bash > > logfile="/data/logs/evolution.log" > > echo "" >> $logfile > echo "--- $(date +"%R %A, %B %-d, %Y") ---" >> $logfile > evolution >> $logfile 2>&1 > --- end --- |