[aclug-L] sed question
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
I am trying to get sed to substitute the value of a variable for
another string. It doesn't seem to want to do it as it only
substitutes "$vari" instead of the value of var.
Is it even possible to use a variable in sed like this? Is there
some special syntax required if it is possible.
Here's what I've tried,
# Get current dynamic local IP address
vari= `tail /var/log/messages | grep local | awk '{ print $9 }'`
# Substitute it into a html file in place of last IP address
sed 's/209\.134\.90\.[0-9]*/$vari/' /temp/test.html > /temp/test2.html
This will insert "$vari" into the correct place in the html file,
but I need it to place the value of vari instead. No matter what I
put between the / and /, that is what it substitutes into the
test2.html file.
Some other things I've tried there:
/{$vari}/
/ $vari /
/{ $vari }/
and several others that I've forgotten. All result in the string
between the /'s being substituted exactly.
The variable is correctly valued with the current IP address. I
have also tried exporting it in the hopes that would let it work
id sed. No such luck.
Help!!!!!
Wayne
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Just allow a fragment of your life. . .
to wander free.
E.J.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- [aclug-L] sed question,
Wayne White <=
|
|