Reputation: 3
I am trying to replace the below indicated string with special characters in a file, in linux. I tried using the backslash in front of every special char, but getting errors. Must be missing something. How do I achieve the below. Thanks in advance:
filter = [ "a/sda[0-9]*$/", "r/sd.*/" ] ---> Replace this line with below line
filter = [ "a/sda[0-9]*$/", "a/sdb[0-9]*$/", "r/sd.*/" ]
Upvotes: 0
Views: 2409
Reputation: 185881
Using awk and columns strategy :
$ awk '{$3=$3 "a/sdb[0-9]*$/\042, "; print}' file.txt
filter = [a/sdb[0-9]*$/", "a/sda[0-9]*$/", "r/sd.*/" ]
Upvotes: 0
Reputation: 195289
for your example, this worked
sed 's@",@", "a/sdb[0-9]*$/",@'
output:
kent$ echo 'filter = [ "a/sda[0-9]*$/", "r/sd.*/" ]'|sed 's@",@", "a/sdb[0-9]*$/",@'
filter = [ "a/sda[0-9]*$/", "a/sdb[0-9]*$/", "r/sd.*/" ]
Upvotes: 1