How many whois searches do you do in a year? A dozen? A dozen dozen? More? For me, it’s probably in the neighborhood of a few dozen dozen.
It seems like there is always a fun new project to work on and, sadly, it’s becoming nearly impossible to find good domain names.
Recently I was looking for a suitable LLC name for a company to hold all my projects. As my wife shouted out name candidates, I found myself repeating paired whois plural/singular queries like:
whois hilltoplab.com whois hilltoplabs.com whois hilltopstudio.com whois hilltopstudios.com
Etc for .org, .biz (haha, not really) and .net…
As a lazy programmer-type, I decided to do a quick Google search to see if someone had a handy bash script available. Lucky for me, D’s Blog did.
For me, the only whois output I am interested in is whether the domain is registered and, if it is not, when it was created (I like playing an annoying little game of “p’shaw…that was registered in 1999′” when I’m offered obviously taken suggestions).
I stripped out a lot of D’s functionality and ended with the following script:
#!/bin/bash echo "" echo "######## WHOIS: "$1 # Whois using the input variable whois $1 |\ # Remove EOL characters tr -d '\015\032' |\ # Remove leading spaces sed 's/^ *//' |\ # Remove common unnecessary words from output grep -v -e "@" -e "http://" -e "WHOIS" > wtmp1.txt # Display all of the date lines egrep -i "ate: " wtmp1.txt # Remove the tmp file rm -rf wtmp1.txt echo "######## DONE!" echo ""
(Don’t forget to chmod 774 your script after you create it).
I also have a little function I tuck in my .bash_aliases
that lumps the singular/plural lookups I want to do.
It looks like this:
function wi() {
~/my_whois.sh "$@"lab.com;
~/my_whois.sh "$@"labs.com;
~/my_whois.sh "$@"studio.com;
~/my_whois.sh "$@"studios.com;
}
So when I type this:
wi hilltop
I get output like this:
######## WHOIS: hilltoplab.com ######## DONE! ######## WHOIS: hilltoplabs.com Updated Date: 18-jun-2009 Creation Date: 28-aug-2000 Expiration Date: 28-aug-2018 ######## DONE! ######## WHOIS: hilltopstudio.com Updated Date: 08-jan-2008 Creation Date: 10-oct-1999 Expiration Date: 10-oct-2013 ######## DONE! ######## WHOIS: hilltopstudios.com Updated Date: 07-aug-2012 Creation Date: 22-aug-2000 Expiration Date: 22-aug-2013 ######## DONE!
Cleanly indicating that, as of this writing, hilltoplab.com is available, but the other variations are not.
Aaahhhhhh……










One Response to “A Bash Script for Quick Whois Queries”
Hi Mitch,
awesome, thanks for the script. You taught me two things today :
1) I can do whois queries on the command line (don’t ask why I have completely missed that for years)
2) An awesome approach to check for new domain names.