一致する文字列を別の文字列に置き換えようとしています。これは私が持っているものです。
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
これは動作しない例外です。
私もフォローしてみました
sed -i 's/$old_string/$new_string/g' /etc/opentsdb/opentsdb.conf
sed -i '/${old_string}/${new_string}/g' /etc/opentsdb/opentsdb.conf
ここで私が何を間違っているのかわかりません。
ベストアンサー1
たとえば、二重引用符を使用する必要があります。
sed -i "s/$old_string/$new_string/g" /etc/opentsdb/opentsdb.conf