Skip to content

Instantly share code, notes, and snippets.

@JustThomas
Last active February 25, 2017 21:49
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 JustThomas/7e47a8426fb4dc86d4f0f911ca65166c to your computer and use it in GitHub Desktop.
Save JustThomas/7e47a8426fb4dc86d4f0f911ca65166c to your computer and use it in GitHub Desktop.
Resolve all domains from a CSV export of the wp_domain_mapping database table
#!/bin/bash
INPUT=wp_domain_mapping.csv
OLDIFS=$IFS
IFS=,
[ ! -f $INPUT ] && { echo "$INPUT file not found"; exit 99; }
while read domainid siteid domain active
do
domain=${domain//\"} # Remove quotes
domainid=${domainid//\"} # Remove quotes
ip=`dig +short $domain | tail -n 1` # Resolve domain name
echo "$domainid,$domain,$ip" # Write output in CSV format
done < $INPUT
IFS=$OLDIFS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment