Chris Hardcastle

Techical developer for websites in London

Wordpress absolute path update

I have just found a really helpful command that I can see myself using all the time. It’s too often that I need to take a copy of a development database file and update the absolute paths to use the live address.

Imagine you have a .sql file that you have created by exporting a wordpress database. That can be done using the mysqldump command over the command line in Linux/Ubuntu. Now you want to replace all (global) occurrences of “local” with “live” in a file called “data.sql” and catch the results in a new file called “new.sql” the code would be as follows.


sed -e 's/local/live/g' data.sql > new.sql


A new file should be created called “new.sql” with the replacements made. SED is a tool available in all Linux distributions and can be accessed via the command line. The “e” command runs the function with the script that follows in quotes. The ’s’ command treats the arguments as separate files. The ‘g’ means global. This makes a replacement on multiple lines.

This is an interpretation based on guidance from this following article it’s a very simple example. For my own reference really, but I hope you find useful.

Tags: ,

Leave a Reply


My Twitter updates

  • hardcastle There's new examples I've not seen already on the #raphaeljs framework website. Pretty cool!
  • hardcastle Wow, couch.io just got a new design and content! #couchdb
  • hardcastle @mark_xDDD it feels very stable. Installation was perfect. It's only good if it fits your needs!
  • hardcastle @mark_xDDD I'm installing kubuntu 10.04 tonight!

youTube videos

Luke gives a half smile

Luke gives a half smile

This video was uploaded from an Android phone.

Duration: 00:23

Views: 85


Lukes first rattle holding experience

Lukes first rattle holding experience

This video was uploaded from an Android phone.

Duration: 00:44

Views: 26