Skip to content

Instantly share code, notes, and snippets.

@StanBright
Last active July 23, 2021 04:26
Show Gist options
  • Save StanBright/b236675e272ace1b385a9a0f2d543a1f to your computer and use it in GitHub Desktop.
Save StanBright/b236675e272ace1b385a9a0f2d543a1f to your computer and use it in GitHub Desktop.
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
@nitinsareen
Copy link

If its taken, what should be shown?

@StanBright
Copy link
Author

It's be blank. Nothing.

You can easily show something by modifying the "if".

e.g.

if [ $? -eq 0 ]; then
 echo "$1${DOMAINS[${i}]} - Available"
else
 echo "$1${DOMAINS[${i}]} - Taken"
fi

@nitinsareen
Copy link

Appreciate this, was intending to highlight that in the else condition if we can detail out further info regarding the occupancy but this is just fine as well. Also ran my domain day before and found out the rest two - .co & .io were taken up today - bad luck or is this too revealing?

@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