Skip to content

Instantly share code, notes, and snippets.

@jacquesbh
Created July 9, 2012 08:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jacquesbh/3075104 to your computer and use it in GitHub Desktop.
Save jacquesbh/3075104 to your computer and use it in GitHub Desktop.
Change the url of a WordPress in bash
function chWpUrl()
{
db=$1
from=$2
to=$3
request="UPDATE wp_options SET option_value = REPLACE(option_value, '$from', '$to');
UPDATE wp_posts SET guid = REPLACE(guid, '$from', '$to');
UPDATE wp_posts SET post_content = REPLACE(post_content, '$from', '$to');
UPDATE wp_comments SET comment_author_url = REPLACE(comment_author_url, '$from', '$to'),
comment_content = REPLACE(comment_content, '$from', '$to')
WHERE comment_type <> '';"
if [[ $4 == 'get' ]]; then
echo $request
else
(echo $request) | mysql $db
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment