Reputation: 177
I have a config file that need to replace DBpass and host ip when deploy
some code look like this:
{DBPASS}@{ip}
I create a scripts file to replace them like this
echo "Host IP?"
read ip
sed -i 's/{ip}/$ip/g' abc.conf
echo "DB pass?"
read dbpass
sed -i 's/{DBPASS}/$dbpass/g' abc.conf
and it turn out to be like this in config file
$dbpass@$ip
So how can I make the sed command in shellscripts replace the word I input before.
Upvotes: 0
Views: 24
Reputation: 195039
change the single quotes '
into double quotes "
in your sed commands, so that the shell variables can be expanded.
Upvotes: 2