I am trying to set an IP in a file with sed. I am running this command
sed -i 's:$dbserver='':$dbserver='10.0.0.2':' t.conf
but when I look in t.conf the line is
$dbserver=10.0.0.2''
Anyone know why the two single quotes are appearing at the end of the line?
I am running Debian Linux
You need to enclose the second
sedargument in double quotes:This way
$dbserverwill be substituted with its value before being passed tosed, and the single quotes won’t need escaping.If you want
$dbserverto appear literally in the conf file, preceed the dollar signs with a backslash.