I have loads of files that need to contain the name


But instead, they contain the following:


but also sometimes

fooJacquelinbar or

123Jacquelin123 or


How do I replace every instance of Jacquelin with Jacqueline, without ending up with things like Jacquelinee?

What I've tried is:

find . -name '*' -type f -exec sed -i 's/\bJacquelin\b/Jacqueline/g' {} +

But this will not replace instances where anything is attached to "Jacquelin" (doesn't match the whole word).


Try also

sed  's/\(Jacquelin\)e\?/\1e/g' file


sed -r 's/(Jacquelin)e?/\1e/g' file

I would recommend using Perl to utilise negative look-aheads

perl -pe 's/Jacquelin(?!e)/Jacqueline/g'

which will replace when Jacquelin is not immediately followed by the character e (this includes if there isn't a character after)

To batch edit files in-place, you can add the -i flag:

find . -name '*' -type f -exec perl -pi -e 's/Jacquelin(?!e)/Jacqueline/g' {} +

Remember to backup before hand as the operation isn't reversible

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.