TMPDIR="/rae/tmp"
SERVER="`hostname`"
sed -i 's/name:/${SERVER}: name/g' $TMPDIR/mounts.$SERVER
Currently in file
------------------------
name: chris
Trying to make the output to the file mounts.$SERVER become:
-------------------------------------------------------------------------------------------
cltgap01: name: chris
Could awk or gawk work better for this? Please help.
Thanks,
Chris
Variables are not expanded inside single quotes.
TMPDIR=/rae/tmp
SERVER=`hostname`
sed -i.bak 's/name:/${SERVER}: name:/' "$TMPDIR/mounts.$SERVER"
--
Chris F.A. Johnson, author | <http://cfajohnson.com>
Shell Scripting Recipes: | My code in this post, if any,
A Problem-Solution Approach | is released under the
2005, Apress | GNU General Public Licence
Which should, of course, have read:
sed -i.bak "s/name:/${SERVER}: name:/" "$TMPDIR/mounts.$SERVER"
Followups redirected to comp.unix.shell where this belongs.