Reputation: 429
I have a sed command in my makefile like following ,purpose of the command is, it should replace string "listen $address" to "",but as a result it is replacing "listen $address" to "$address"
sed -i -e "s/listen $$address//" file.txt
Please suggest any solution. I have checked many posts but there $ is used as regex variable ,in my case it needs to be treated as hardcoded string
Upvotes: 1
Views: 470
Reputation: 15461
Enclose your sed command in single quotes to avoid variable expansion within double quotes:
sed -e -i 's/listen $address//' file
You can use double quotes though by escaping the $
:
sed -e -i "s/listen \$address//" file
Upvotes: 1