[Novalug] Appending commands to a shell script file

Robert Kuropkat robert@kuropkat.com
Fri Mar 1 15:31:55 EST 2013


*This message was transferred with a trial version of CommuniGate(tm) Pro*

You might also try using a here doc.  Sometimes that makes the quoting 
easier and code cleaner looking.

There are a few variations on the theme so  you may have to play with it 
a little find the form that works best for you.

http://linux.die.net/abs-guide/here-docs.html
http://www.codeproject.com/Articles/102769/LINUX-The-Power-of-HERE-Documents

Robert Kuropkat


On 3/1/2013 7:46 AM, Matt Rowley wrote:
> *This message was transferred with a trial version of CommuniGate(tm) Pro*
> Remove the backticks.
>
>
> On Mar 1, 2013, at 7:33 AM, Tony Jones <tjones12305@gmail.com> wrote:
>
>> Hi,
>>
>> I want to create a shell script that appends the output to a file using the echo statement.  I want to append the below to a shell script file - testfile.sh  This is just an example, but is close to what I want to accomplish.  However, when I execute the script in debug mode the output of YMD is the actual date or YMD=20130301.  My question is how to append the string with the date command to a file without executing the date command? In other words,  I want the file testfile.sh to have the line YMD=`date +"%Y%m%d"` and not YMD=20130301.  I know this is a strange way to do this.
>>
>> TESTFILE=/tmp/testfile.sh
>> LOGFILE=/tmp/logfile
>> touch $TESTFILE
>> echo "#!/bin/sh" > $TESTFILE
>> echo "#Test File" >> $TESTFILE
>> echo "YMD=`date +"%Y%m%d"`" >> $TESTFILE
>> echo "LOGFILE=/tmp/$YMD-test.log" >> $TESTFILE
>> echo "/bin/rpm -qa mysql > $LOGFILE" >> $TESTFILE
>>
>> Thanks,
>> Tony
>> _______________________________________________
>> Novalug mailing list
>> Novalug@calypso.tux.org
>> http://calypso.tux.org/mailman/listinfo/novalug
> _______________________________________________
> Novalug mailing list
> Novalug@calypso.tux.org
> http://calypso.tux.org/mailman/listinfo/novalug




More information about the Novalug mailing list