During the hunt for available domain names, I make frequent use of the whois utility from a Linux command line. I have never trusted web-based whois tools. You never know if your searches are being stored. Also, I haven’t found a web-based whois that is as flexible as a shell script. So, I’ve written a simple set of scripts to aid in the search for domains to register. I must warn you, it’s not pretty, but I hope you’ll find it useful.

NOTE: For reasons which I cannot fathom, the whois utility isn’t available by default on all *nix systems. On Debian, Ubuntu, and Mint, you can install it using the command
sudo apt-get install whois.

First, here is the code for wi.sh (so called because I wish I could find a gem):

# This program is free software, licensed under the GNU GPL, >=2.0.
# This software comes with absolutely NO WARRANTY. Use at your own risk!
# wi.sh v0.1.0
# Author: Tim Kissane
# Check the whois record for the existence of a domain
# that I wi.sh I could buy. :)


if [ “$tld” = “” ] # if no second arg, default to .com

if [ “$tld” = “.ca” ]

if [ “$tld” = “.ly” ]

if [ “$tld” = “.co.uk” ]

if [ “$tld” = “.net.au” ] || [ “$tld” = “.com.au” ]

echo Checking whois for $name$tld

if [ “$tld” = “.co.za” ]
whois $name$tld
whois $name$tld > /tmp/$name.tmp
grep $term /tmp/$name.tmp
rm /tmp/$name.tmp

# Be nice to the whois server
sleep $timer

Put the attached script, wi.sh in your path and make it executable.
chmod 755 wi.sh

By default, the script uses .com as the TLD, to to only check for
available .coms, run this:

wi.sh isthisavailable

You will get something like this back:

Checking whois for isthisavailable.com
Expiration Date: 15-nov-2012

Since it has an expiration date, it is not available to register.

If you want to check a different tld, say .net, do this:

wi.sh isthisavailable .net

Notice the space between the name and the TLD.
The output of this (at this moment) is:
Checking whois for isthisavailable.net

No “Expiration” line, so it’s available.
This works for most, but not all TLDs. More code is needed for certain other TLDs.

Ok, you really want a bulk checker, something that can check hundreds or thousands of names.  That brings us to the next case, using a text file for input.

Put one name on each line of a file, without a TLD, like so:


Save it as sample.txt.

Running this:

for dn in `cat sample.txt`; do wi.sh $dn; done

This dumps one line at a time into the wi.sh script.  As it runs, it produces the following output:

Checking whois for sex.com
Expiration Date: 17-oct-2019
Checking whois for drugs.com
Expiration Date: 18-dec-2019
Checking whois for rock.com
Expiration Date: 17-sep-2019
Checking whois for and.com
Expiration Date: 16-dec-2010
Checking whois for roll.com
Expiration Date: 24-may-2011
Checking whois for jimihendrixisonewiththeuniverse.com

The first 5 are, unsurprisingly, not available.  The last name has no
“Expiration” line and is available to register. (go ahead, I don’t mind) 🙂

To do this with a different TLD, just add it into the command:

for dn in `cat sample.txt`; do wi.sh $dn .net; done

Now, for a really long list of names, this is a pain to watch the scrolling
output and will make your eyes glaze.  To save the ouput to a file, use

for dn in `cat sample.txt`; do wi.sh $dn .net; done > output.txt

Or, if you want to watch the scrolling results and save to a file, use a pipe to tee:

for dn in `cat sample.txt`; do wi.sh $dn .net; done | tee output.txt

This is better, but who wants to pore through hundreds or thousands of lines
in output.txt looking for the available names?  Not me!

That’s when we use the next script, multilinegrep.pl, a short perl job
which should run on any *nix system with perl installed.

Save this code as ‘multilinegrep.pl’:

#!/usr/bin/perl -w
# This program is free software, licensed under the GNU GPL, >=2.0.
# This software comes with absolutely NO WARRANTY. Use at your own risk!
# multilinegrep v0.1.0
# Author: Tim Kissane
# A small utility to find consecutive lines that begin
# with "Checking" in the output of wi.sh


while () {
if (/^Checking/)
if ($match==”1″)
print substr ($lastline, 19);
} else {

Again, place the script somewhere in your path and make it executable.
Then, run it like this:

multilinegrep.pl output.txt

This will find any available domains.  But wait!  It doesn’t work with this
sample ouput.txt! My perl script misses the last line. 🙁  Until I fix it, here’s the

for dn in `cat sample.txt`; do wi.sh $dn; done |tee output.txt; echo Checking >> output.txt

The echo at the end adds a line begining with “Checking” at the end of the file. Now, it works. So,

multilinegrep.pl output.txt



This can also be saved to a file,

multilinegrep.pl output.txt | tee available.txt

You can copy and paste the contents of available.txt into the form at valuate.com, estibot.com, godaddy.com or any where else you like. I will sometimes run several of these while sleeping, then I can register any found treasures in the morning.

In Part Two, I’ll add a few tips and tricks to perform even more powerful searches.

( image courtesy of cosmosmagazine.com )

Do not use, republish, in whole or in part, without the consent of the Author. TheTAZZone policy is that Authors retain the rights to the work they submit and/or post…we do not sell, publish, transmit, or have the right to give permission for such…TheTAZZone merely retains the right to use, retain, and publish submitted work within it’s Network.

By Tim Kissane

Linux and Open Source consultant/speaker, domainer, techie, spiritual explorer, guitarist, dreamer.