Re: [aclug-L] sed question
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
On Sun, 22 Aug 1999, Wayne White wrote:
> 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.
>
Try using double quotes instead of single quotes for the sed command.
Good luck.
----------------------------------------------------------------------------
SANJAY DHAR
sxdhar@xxxxxxxxxxx
http://www.cs.twsu.edu/~sxdhar
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|