Text Editors Freezing on Search & Replace

I created a script that is run via cron that backs up the database of one of my websites, gzips it, and emails it to me. It works great, but I like to use a text editor to search and replace the domain name, so that I can use it in a development environment. As the backup file has been getting larger, I’ve reached the point where neither Sublime Text or gedit will do a “Replace All” without totally freezing. Linux makes this a non-issue:

#search for production.com and replace with dev.com
sed -i 's/production.com/dev.com/g' ./production-dump.sql

#overwrite dev database
cat ./production-dump.sql | mysql -u username -ppassword database

Posted May 6th, 2015 in

Leave a comment