biz5pw
Last Updated: February 25, 2016
·
1.284K
· jwebcat

use sed -i to replace in place on a string in a file

use this handy bit to replace in place a string in a file.

sed -i 's#string#otherstring#g' filename

and you will be replacing strings with ninja speed.

I use this to keep my database in sync with WordPress

  • Just make sure that you that your dev url and your production url are the same length otherwise you will have serialization issues. (namely all the widgets and their settings)

  • In order to avoid this caveat of monkeypatching my sql file, I make an entry in my host file to have both urls the same length. e.g.

127.0.0.1    somewebsite.dev

and then an entry in my apache virtual hosts file to redirect somewebsite.dev to localhost/sites/somewebsite

dev url: http://somewebsite.dev

production url: http://somewebsite.com

and then it plays nice with WordPress just dandy.

enjoy!