user3893307
user3893307

Reputation: 21

sed command replacing string that contains special character is not working

i want to replace a special string inside a file.txt. my strings are like this :
-> Old String

tech=/lsf/dfg/a.v,/ldf/fgh/b.v

-> New String

tech=$var    

i have tried following

sed -i 's/tech=/lsf/dfg/a.v,/ldf/fgh/b.v/tech=$var/g' file.txt   

it doesnt work.

Upvotes: 0

Views: 138

Answers (1)

Jean-Pierre
Jean-Pierre

Reputation: 171

sed -i 's#tech=/lsf/dfg/a.v,/ldf/fgh/b.v#tech=$var#g' file.txt

Just replace the delimiters '/' for the sed expression with '#' (or another character that is not in the string you are trying to match and replace).

Upvotes: 1

Related Questions