10-03-04 07:48 AM
On 3 Oct 2004 00:01:56 -0700, Cologne <cologne_2003@yahoo.com>
wrote:
> Hi there,
>
> How can I expand a variable in sed expression...For eg. I have
> the following
>
> sed '/s\/bin\/httpd/bin\/httpd \-f' `$HTTPD_DIR`\/conf\/httpd/\
> sal > sal.new
>
> Now the sed expression literally puts the $HTTPD_DIR in sal.new
> file...I want it to put the value of $HTTPD_DIR of it in the
> file... how can I acheieve that...
>
That isn't going to put anything anywhere. Try following this
general pattern:
sed "s:/dir/dir:/dir${VAR}:" > file
Use double quotes to allow expansion, ":" as a seperater instead
of "/" to make it easier to read and keep track of what's what,
and enclose the variable in curly braces "${VAR}" to make sure
that adjacent characters aren't included in the variable name.
HTH
AC
[ Post a follow-up to this message ]
|