Last active
February 25, 2017 21:49
-
-
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
This file contains hidden or 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
#!/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