On a recent project, I was given a list of about 30 domains to redirect to a new site. I needed to get a handle on where the domains were registered and where the DNS was hosted. I could have spent a lot of time typing “whois domain-name.com” into the terminal of my Mac, or write a shell script to do the lookups for me and write the results to a file that I could quickly examine. I already had all the domains in a text file. Here’s what I did:
#!/bin/bash for domain in `cat domains.txt` do echo $domain `whois $domain >> whois-results.txt` done
You could take this a step further and do some regular expression matching to only get the lines of interest, but this needed to be quick and dirty.