Created
July 9, 2012 08:32
-
-
Save jacquesbh/3075104 to your computer and use it in GitHub Desktop.
Change the url of a WordPress in bash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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