0

I want to replace filter = [ "a/.*/" ] with

filter = [ "a\/sda1\/", "a\/sdb\/", "r/\.\*\/"]

I have tried this regex

sed -i -r 's/\s+filter\s=.*/'filter = [ "a\/sda1\/","a\/sdb\/", "r/\.\*\/"]'/' conf But getting this error. Please advice.

sed: -e expression #1, char 23: unterminated `s' command
Harikrishnan
  • 9,688
  • 11
  • 84
  • 127

1 Answers1

2

The problem is you are using the / delimiter more in the field ,instead of / use some other delimiter like s#pattern#replace# . Another thing is you have to replace each and every special meaning character to literal values . So The below command are helpful to get expect result.

sed  -r -i -e 's#(filter = )(\[ "a/\.\*/" \])#\1[ "a\/sda1\/", "a\/sdb\/", "r/\.\*\/"]#g' conf
Harikrishnan
  • 9,688
  • 11
  • 84
  • 127
Kalanidhi
  • 4,902
  • 27
  • 42