Whois Shell Script

I've got loads of little scripts that I've written lying around my hard drive. Some I've probably only used once and never looked at again, and others I use regularly. I thought I would post some of them here.

Here is a simple shell script that I wrote that performs a whois lookup of every domain name in a given file and outputs the registrant details:

# usage: $0 <domains file>
domains=`cat $1`
for domain in $domains
    stripped_domain=${domain#www.} # strip a leading www.
    reg=`whois $stripped_domain | grep -i -A 1 registrant: | tail -n 1`
    echo "[$domain] $reg"

Given an input file containing the following domains

The script will output

[]     B. Dowling
[]        Google Inc. (DOM-258879)
[]       Matt Mullenweg
[]    Facebook, Inc

Obviously this is one of those scripts that I used once and never looked at again! :)

Posted on 08 Mar 2008
If you enjoyed reading this post you might want to follow @coderholic on twitter or browse though the full blog archive.