concatenate string in shell script

Stuart Jansen sjansen at buscaluz.org
Thu Mar 16 09:58:37 MST 2006


On Thu, 2006-03-16 at 09:05 -0700, Corey Edwards wrote:
> I recommend always putting variables in {} and "". {} prevents your
> variables from being confused with string literals. "" prevents spaces
> from causing problems.

#!/bin/sh
file="/mnt/windows/My Documents/notes.txt"
tensai="Corey"
mesg="The world would be a better place"
mesg="${mesg} if everyone listened to ${tensai}'s advice."
echo "$mesg" >> "$file"
mesg="${mesg/a better/an even better}"
echo "${mesg/Corey/Stuart}" >> "$file"

-- 
Stuart Jansen              e-mail/jabber: sjansen at buscaluz.org
                           google talk:   stuart.jansen at gmail.com
:0                         # copy & paste for your convenience
* ^From:.*sjansen@
/dev/null                  # /ignore sjansen!*@*
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 191 bytes
Desc: This is a digitally signed message part
Url : http://plug.org/pipermail/plug/attachments/20060316/8c83f64f/attachment.bin 


More information about the PLUG mailing list