Skip to content

Instantly share code, notes, and snippets.

@chrisjangl
Created November 24, 2021 12:28
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 chrisjangl/7362db6ae26ff211b7d7dbe268506ab3 to your computer and use it in GitHub Desktop.
Save chrisjangl/7362db6ae26ff211b7d7dbe268506ab3 to your computer and use it in GitHub Desktop.
Working from a list of WordPress sites on a shared hosting environment (sites.txt), this script will print the DB name and login URL for each site.
i=1
touch urls.txt
COUNT=$(wc -l sites.txt)
for SITE in $(cat sites.txt)
do
cd $SITE
echo "Working on $SITE ($i of $COUNT)..."
echo "## $SITE" >> ../urls.txt
url=$(wp option get siteurl)
postURL="/wp-login.php"
db=$(wp config get DB_NAME)
echo "DB: $db" >> ../urls.txt
echo $url$postURL >> ../urls.txt
echo "----------------" >> ../urls.txt
echo " " >> ../urls.txt
echo " " >> ../urls.txt
echo " " >> ../urls.txt
((i=i+1))
clear
cd ..
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment