0

I am trying to replace matching string with other string. This is what I have

ZKHOSTS="host1,host2,host3"
old_string="tsd.storage.hbase.zk_quorum*"
new_string="tsd.storage.hbase.zk_quorum = $ZKHOSTS"

sed -i '/$old_string/c\$new_string' /etc/opentsdb/opentsdb.conf

which isn't working as excepted.

I even tried following

sed -i 's/$old_string/$new_string/g' /etc/opentsdb/opentsdb.conf

sed -i '/${old_string}/${new_string}/g' /etc/opentsdb/opentsdb.conf

I dont know what wrong I am doing here.

rp346
  • 1,389

1 Answers1

2

You must use double quotes, like:

sed -i "s/$old_string/$new_string/g" /etc/opentsdb/opentsdb.conf
DisplayName
  • 11,688