sed string replacement

Here’s how you can replace a string in a file with sed:

perl -pi -e ‘s/replaceme/reoplacewith/g’ filename.txt

This is a VERY basic replacement without and special characters. Be VERY careful if you have special characters that you’re trying to replace. If you have characters like:
/ you will have to proceed them with a \ to ensure you don’t wipe out the file.

Leave a Reply

You must be logged in to post a comment.