Link to home
Create AccountLog in
Avatar of joaotelles
joaotellesFlag 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
Avatar of woolmilkporc
woolmilkporc
Flag of Germany image

sed -i 's/'${host_db}'/'${new_db}'   db-01/' /etc/hosts
ASKER CERTIFIED SOLUTION
Avatar of woolmilkporc
woolmilkporc
Flag of Germany image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of joaotelles

ASKER

Tks.