Avatar of joaotelles
joaotelles
Flag for United States of America asked on

Shell - sed not replacing variables

Hi,

Im using this sed command in order to replace a line in the hosts file but as I run the script it looks like its not replacing the variables per their value...

sed -i 's/${host_db}/${new_db}   db-01/' /etc/hosts

Running using sh -x I get this:
+ new_db=10.216.193.68
+ host_db='12.18.1.61   db-01'
+ sed -i 's/${host_db}/${new_db}   db-01/' /etc/hosts


Anything I might be missing?

Tks,
Joao
Shell Scripting

Avatar of undefined
Last Comment
joaotelles

8/22/2022 - Mon
woolmilkporc

sed -i 's/'${host_db}'/'${new_db}'   db-01/' /etc/hosts
ASKER CERTIFIED SOLUTION
woolmilkporc

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
joaotelles

ASKER
Tks.
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck