I specialise in creative use of digital media, copywriting, and bright ideas.

I'm into technology, the arts, electronic music, design and typography, public information campaigns, and many weird and wonderful things in between.


Bash script to bulk check UK domains

I am trying to learn Bash scripting. This one performs Nominet whois lookups (checks the availability of .uk domains). Disclaimer: I don't know how well-formed it is - probably not very. Use at your own peril!

#!/bin/bash

clear; echo Checking domains

i=0;
for var in "$@"
do
    tput sc; tput cup 0 0; echo '                      '
    tput cup 0 0; echo Checking $var
    tput rc

    whois $var.org.uk | grep "No match"
    whois $var.co.uk | grep "No match"

    let i++;

    if [ $i == 2 ]; then
      tput sc; tput cup 0 25; echo 'Waiting politely...'
      sleep 1;
      tput cup 0 25; echo '                   '
      tput rc
      i=0;
    fi

done

Syntax:

./nominet.sh thisoneisnttaken coaxed residual fairlight braincheese meltface

Sample output:

Checking meltface
No match for "thisoneisnttaken.org.uk".
No match for "thisoneisnttaken.co.uk".
No match for "coaxed.org.uk".
No match for "coaxed.co.uk".
No match for "residual.org.uk".
No match for "braincheese.org.uk".
No match for "braincheese.co.uk".
No match for "meltface.org.uk".

The 'Waiting politely' part inserts a delay; Nominet allows up to 5 queries per second. However, you're only allowed 1,000 requests per day, so be careful. Read and understand Nominet's whois Acceptable Use Policy.