Posted by ant
February 13th, 2009
Filed in Sysadmin
I develop quite a number of Wordpress sites. I tend to do this on a subdomain before putting the site live. When putting them live Wordpress you have to change loads of references in the database both to the directory the site resides in on the server and the URL of the site itself. I normally use TextMate for my text editing needs. However, it’s really slow at search and replace. So I used sed This does it really, really fast. To do a global search and replace on a file…
sed 's/searchstring/replacedstr/g' <infile.txt >outfile.txt
Which performs a substitute (s) globally (g). Don’t forget to escape necessary regular expression characters such as / and . So in the above context
sed 's/sub\.testdomain\.com/www\.realdomain\.com/g' <dump.sql >outdump.sql
Blog uses Mephisto
Design from OSWD
by dreamLogic

Leave a Reply ☆