I wanto replace # SigningTable refile:/etc/opendkim/SigningTable
to SigningTable refile:/etc/opendkim/SigningTable
.
Which means just remove #
.
I use sed -i 's/# SigningTable refile:/etc/opendkim/SigningTable/ SigningTable refile:/etc/opendkim/SigningTable/g' /etc/opendkim.conf
,but doesn't work.
I think it's because /
,how to use sed to replace string with /
?
Asked
Active
Viewed 49 times
0
1 Answers
1
You can change the delimiter:
sed -i 's!TEXT!REPLACE!' file
You can use this, if SigningTable appears once in the file:
sed '/SigningTable/{s/^# *//}' in
or be more specific:
sed '\@refile:/etc/opendkim/SigningTable@{s/^#//}' in

perreal
- 94,503
- 21
- 155
- 181
-
doesn't work .can be reproductive by `yum install opendkim`. – kittygirl Oct 24 '18 at 03:35
-
updated with some other possible solutions. It may be that there is a tab character before the `refile`. – perreal Oct 24 '18 at 03:49
-
I use `p` to show the line, nothing appear. – kittygirl Oct 24 '18 at 03:49
-
use a sub-string on that line. – perreal Oct 24 '18 at 03:50
-
`SigningTable` appears lots of times.You are right, it's `tab character`, when I copy to `windows`,`tab` become `space`.Then, any solution for `tab in sed`. – kittygirl Oct 24 '18 at 03:53
-
try `\t`, if that fails look at: https://stackoverflow.com/a/2610121/390913, or you can use a `.` instead of a tab. – perreal Oct 24 '18 at 03:55
-
1you can skip parts of the string with `.*` too, for example `SigningTable.*/etc/...` – perreal Oct 24 '18 at 03:56