MERose
MERose

Reputation: 4421

How to replace one of multiple possible strings followed by zero or more periods

I try to remove JR. Jr jr. with sed -i "s/(Jr\|JR\|jr)\.*//g" but it doesn't work. Why and what should I do?

Upvotes: 0

Views: 18

Answers (1)

Gilles Quénot
Gilles Quénot

Reputation: 185189

You have to backslash parenthesis too, so :

sed -i "s/\(Jr\|JR\|jr\)\.*//g"

or :

sed -i -r 's/(Jr|JR|jr)\.*//g'

or even better :

sed -i -r 's/jr\.*//ig'

Upvotes: 2

Related Questions