Skip to content

Instantly share code, notes, and snippets.

@canonex
Last active July 25, 2022 16:51
Show Gist options
  • Save canonex/0fff3cf2de03d789df7a3faa5ab2c0bf to your computer and use it in GitHub Desktop.
Save canonex/0fff3cf2de03d789df7a3faa5ab2c0bf to your computer and use it in GitHub Desktop.
Wordpress dump siteurl extractor
#!/bin/bash
#If working from a dump
DB=mydb.sql
grep -F "'siteurl'," "$DB" | head -c 200 | sed 's/, /,/g' | sed 's/^.*\(siteurl.*\)/\1/g' | sed "s/'/ /g" | egrep -o 'https?://[^ ]+' | head -1
#If working in a wordpress env with wp-cli
#wp db query "SELECT option_value FROM $(wp config get table_prefix)options WHERE option_name='siteurl'" --skip-column-names
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment