Skip to content

Instantly share code, notes, and snippets.

@StanBright
Last active Jul 23, 2021
Embed
What would you like to do?
Domain Name Search
#!/bin/bash
# Name: Check for domain name availability (as featured on https://stanbright.com/domain-name-search)
#
# To use this script, add it to your ~/bin directory and make it executable.
# Then you can search for specific domains like this: > domain_check.sh my-new-domain
#
# Alternatively:
# - Generate domain name ideas based on a keyword: https://www.saashub.com/namebounce-alternatives
# - Search domain names as you type: https://www.saashub.com/domaintyper-alternatives
#
# Please copy, share, redistribute and improve (linuxconfig.org)
if [ "$#" == "0" ]; then
echo "You need tu supply at least one argument!"
exit 1
fi
DOMAINS=( '.com' '.io' )
ELEMENTS=${#DOMAINS[@]}
while (( "$#" )); do
for (( i=0;i<$ELEMENTS;i++)); do
whois $1${DOMAINS[${i}]} | egrep -q '^No match|^NOT FOUND|^Not fo|AVAILABLE|^No Data Fou|has not been regi|No entri'
if [ $? -eq 0 ]; then
echo "$1${DOMAINS[${i}]} - available"
fi
done
shift
done
@jarrodoxical
Copy link

whois was throwing an error for newly released TLDs on my old system
getaddrinfo(whois.dotproregistry.net): Name or service not known

so instead I used the less accurate, less detectable host nameserver lookup technique:
host -t ns $1${DOMAINS[${i}]} | egrep -q '^No match|^NOT FOUND|^Not fo|AVAILABLE|^No Data Fou|has not been regi|No entri|not found'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment