Tom
Tom

Reputation: 9653

sed - is this replacement with a dot is right or should I escape it?

sed -i '' -e 's/firstdomain.com/seconddomain.com/g'

Should I escape the dot? if so how can I do that?

Upvotes: 0

Views: 55

Answers (1)

glenn jackman
glenn jackman

Reputation: 247062

Dot is a regex metacharacter meaning "match any character", so yes you do need to escape it:

sed -i '' -e 's/firstdomain\.com/seconddomain.com/g'

Within a bracket expression, dot loses its special meaning, so you could do this:

sed -i '' -e 's/firstdomain[.]com/seconddomain.com/g'

If you don't escape it, the string "firstdomain-com" (among others) would match

Upvotes: 1

Related Questions