_do_whois(){ if [[ $(whois -H -h "$1" "$2" | grep -o "$3") == "$3" ]]; then echo "$(tput setaf 3)$(tput bold)$2$(tput sgr0) $(tput setaf 3)is available.$(tput sgr0)" else echo "$(tput setaf 1)Domain unavailable. ($(tput bold)$2$(tput sgr0)$(tput setaf 1))$(tput sgr0)" fi } getclick() { _do_whois "whois.uniregistry.net" "$1.click" "is available for registration" } getclub() { _do_whois "whois.nic.club" "$1.club" "Not found:" } getlink() { _do_whois "whois.uniregistry.net" "$1.link" "is available for registration" } getninja() { _do_whois "whois.unitedtld.com" "$1.ninja" "Domain not found" } gettop() { _do_whois "whois.nic.top" "$1.top" "No match" } getwork() { _do_whois "whois-dub.mm-registry.com" "$1.work" "Not Registered" } getxyz() { _do_whois "whois.nic.xyz" "$1.xyz" "DOMAIN NOT FOUND" } nwhois(){ tld=$(echo "$1" | cut -d '.' -f 2) if [ -z $tld ] || [[ "$tld" == "$1" ]]; then #echo "No valid domain." 1>&2 #return tld='all' fi domain=$(echo "$1" | cut -d '.' -f 1) case $tld in "click") getclick $domain ;; "club") getclub $domain ;; "link") getlink $domain ;; "ninja") getninja $domain ;; "top") gettop $domain ;; "work") getwork $domain ;; "xyz") getxyz $domain ;; '*'|"all") getclick $domain getclub $domain getlink $domain getninja $domain gettop $domain getwork $domain getxyz $domain ;; *) echo "Unknown TLD. Falling back to standard whois." whois -H "$1" ;; esac }