I have a file with multiple lines containing a string : ; Ltd that I want to change to Ltd. I tried :

sed -e 's/; Ltd/ Ltd/ig' file

Sometimes it is also ; ltd so I added the i tag for case insensitivity but it won't work for either. Tried to add and remove -e too.


This should work as it will find both upper and lower case L:

sed 's/; [Ll]td/ Ltd/g' file

Don't forget to add the -i to actually write the changes to the file.

sed -i 's/; [Ll]td/ Ltd/g' file
  • oh it was the -i missing, I'm barely a sed user. – ChiseledAbs Dec 12 '16 at 19:20

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.