Site Overlay

How to search and replace with SED on a large file.

Sometimes you’ll end up with larger files that, when you try to run a simple find / replace operation, will error out or not start because there is insufficient memory.

A solution I found in Ubuntu with the sed command is as follows:

sed -i "s|search|replace|g" yourFile.txt

I’m using | as separator to support URLs. This is useful when replacing URLs in SQL files when migrating from one domain to another or fixing an SSL mixed content issue.

Leave a Reply

Your email address will not be published. Required fields are marked *