· 8 years ago · Jul 20, 2018, 08:56 AM
1#!/bin/sh
2# "Cute" domain search -- < oogali AT gmail.com >
3#
4# Example:
5# [oogali@illusion ~]$ ./cute-domain-search am 2
6# IL.AM IS AVAILABLE
7# LE.AM IS AVAILABLE
8# LY.AM IS AVAILABLE
9# OG.AM IS AVAILABLE
10# OL.AM IS AVAILABLE
11# QT.AM IS AVAILABLE
12# ST.AM IS AVAILABLE
13# TI.AM IS AVAILABLE
14#
15# And yes, it pains me that the documentation is more lines than the
16# actual script itself
17
18if [ $# -ne 2 ]; then
19 echo "$0 <tld> <# of letters>"
20 exit 1
21fi
22
23tld=${1}
24letters=${2}
25
26rs=`dig ${tld} @a.root-servers.net ns +noadditional +noquestion +nostats +nocomments | grep "^${tld}" | awk '{ print $5 }' | head -1`
27for domain in `egrep "^[A-Za-z]{${letters}}${tld}\$" /usr/share/dict/words | tr '[A-Z]' '[a-z]' | sort | uniq | sed "s/${tld}\$//"` ; do
28 dig ${domain}.${tld} ns @${rs} | grep -q 'NXDOMAIN' && echo "${domain}.${tld} is available" | tr '[a-z]' '[A-Z]'
29done