Want To Do a Quick Find/Replace? Use ‘sed’!

If you're new here, you may want to subscribe to my RSS feed.

If you are ever need to do just a quick and simple find and replace and don’t want to do it in an editor? You can use the sed command.

If you are familiar with vi, the find and replace string will be very familiar. The format of the find and replace is:

sed 's/oldstring/newstring/g' file.txt

However, if you are wanting these changes to be reflected in a file, you will need to perform an output at the end of your sed string, like so:

sed 's/oldstring/newstring/g' file.txt
> changedfile.txt

I have provided an example of how to use the principles below:

Leave a Reply