TheTAZZone - Internet Chaos

Domain Checker Shell Script Part One

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 (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!
# v0.1.0
# Author: Tim Kissane
# Check the whois record for the existence of a domain
# that I I could buy. :)


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

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

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

if [ “$tld” = “” ]

if [ “$tld” = “” ] || [ “$tld” = “” ]

echo Checking whois for $name$tld

if [ “$tld” = “” ]
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, in your path and make it executable.
chmod 755

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

You will get something like this back:

Checking whois for
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: isthisavailable .net

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

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 $dn; done

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

Checking whois for
Expiration Date: 17-oct-2019
Checking whois for
Expiration Date: 18-dec-2019
Checking whois for
Expiration Date: 17-sep-2019
Checking whois for
Expiration Date: 16-dec-2010
Checking whois for
Expiration Date: 24-may-2011
Checking whois for

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 $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 $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 $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,, a short perl job
which should run on any *nix system with perl installed.

Save this code as ‘’:

#!/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


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: 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 $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, output.txt


This can also be saved to a file, output.txt | tee available.txt

You can copy and paste the contents of available.txt into the form at,, 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 )

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.

Leave a Reply

Your email address will not be published. Required fields are marked *


If you'd like to advertise on The Mutt ( aka ) feel free to contact us at: administration[at]

TheTAZZone is a non-commercial entity. We do not sell any products or services ourselves. Our revenue comes from advertising and donations only.

We appreciate your support! Your advertising revenue ( or donations ) helps us to continue to upgrade, improve, and offset the costs of maintaining this site.

Donations can be made through the page ' Donate '.