Rick Hurst Web Developer in Bristol, UK

Menu

Search and replace on a large file on OSX using Sed

My code editor of choice, Sublime text 2, crashes when you try to do a search and replace on a large file. This makes it difficult to do a search and replace on a large sql file, as I sometimes need to do when moving a wordpress site from one domain to another

The command-line tool sed can be used instead like this:-

sed -i '.backup' 's/olddomain/newdomain/g' wordpress-backup.sql

This makes a backup of the original file, then updates the original