Skip to content

Instantly share code, notes, and snippets.

@whyisjake
Created February 8, 2013 00:24
Show Gist options
  • Save whyisjake/4735519 to your computer and use it in GitHub Desktop.
Save whyisjake/4735519 to your computer and use it in GitHub Desktop.
Shell script that updates the wp-config.php file to the database name. Useful when you manage a lot of different sites.
#!/bin/bash
if [[ "$1" = "" ]]
then
echo "Usage: $0 dbname";
exit 0;
fi
FILE="/Users/jspurlock/Sites/wp-config1.php"
#FILE="/Users/jspurlock/Sites/wp-config.php"
DB_NAME="$1"
echo "Comment out all define DB_NAME lines"
sed -i.bak '/DB_NAME/ s/^define/\/\/define/' $FILE;
#sleep 5;
echo "Uncomment DB_NAME: $DB_NAME"
sed -i.bak "/$DB_NAME/ s/^\/\/define/define/" $FILE;
exit 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment