Skip to content

Instantly share code, notes, and snippets.

@samjsharpe
Created June 18, 2015 21:26
Show Gist options
  • Save samjsharpe/f264d00a8a95d399d2ca to your computer and use it in GitHub Desktop.
Save samjsharpe/f264d00a8a95d399d2ca to your computer and use it in GitHub Desktop.
Clean up government domain list
curl -s https://www.gov.uk/government/uploads/system/uploads/attachment_data/file/362257/List_of_gov_uk_domain_names_as_at_1_October_2014.csv | \
cut -d, -f1 | \
while read line; do
whois -h whois.ja.net $line > tempfile;
OWNER=`egrep -A1 "(Domain Owner|Registered For)" tempfile | awk 'NR==2 {for (i=1; i<=NF; i++) printf("%s%s", $(i), i<NF ? OFS : "\n");}'`;
POSTCODE=`/opt/boxen/homebrew/opt/gnu-sed/libexec/gnubin/sed -rn 's/.*(([A-Z]{1,2}[0-9]{1,2}|[A-Z]{1,2}[0-9][A-Z]) [0-9][A-Z]{2}).*/\1/p' tempfile` ;
grep -q "No such domain" tempfile || print $line,$OWNER,$POSTCODE;
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment