How to replace using SED?

Hi,

I want to change a particular string in a file with another string. This is part of a larger script file. I m using SED for this purpose:

sed -e 's/hostname.domainname/${HOST}.${DOMAIN}/g' $sed_file>$tmp_file

Where the occurance hostname.domainname has to be replaced with the hostname and domain values. But, I find that the resultant temp file ($tmp_file) contains $HOST and $DOMAIN instead of the values stored in them!

I have tried:
${HOST}.${DOMAIN}
`${HOST}.${DOMAIN}`
"${HOST}.${DOMAIN}"
.
What ever be the case, the value given between / & / is occuring as is. Is there a way by which I can print the values stored in the variables $HOST and $DOMAIN?

Regd,
M

use the following

notice the double quotes in sed
Gaurav

Drop the braces around the variables.

Rememebr to use double quotes " " instead of single quotes ' '

Try it out.

Thanks for the reply. Using double quotes solved the problem.

Regd,
M

mahatma,

You could try

HOST=hostname
DOMAIN=domainname
echo "s/hostname.domainname/$DOMAIN.$HOST/\nwq" | ex Filename

If you just want to change the original file.

For example:
Before
#>cat filename
This is hostname.domainname text file

After
#>cat filename
This is domainname.hostname text file

MPH