I am a new to scripting. I am working with a script to replace the
word 'name' in a file with the name of the server. I am trying pass a
variable in a search and replace command using sed. It works now, but
only replaces the word 'name' with the '${SERVER}: name' and not the
actual hostname.
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
word 'name' in a file with the name of the server. I am trying pass a
variable in a search and replace command using sed. It works now, but
only replaces the word 'name' with the '${SERVER}: name' and not the
actual hostname.
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