Ek1234
Ek1234

Reputation: 429

sed command in make file with hard coded $

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

Answers (1)

SLePort
SLePort

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

Related Questions