Skip to content

Instantly share code, notes, and snippets.

@StanBright

StanBright/domain_check.sh

Last active Sep 19, 2020
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
@nitinsareen

This comment has been minimized.

Copy link

@nitinsareen nitinsareen commented Sep 18, 2020

If its taken, what should be shown?

@StanBright

This comment has been minimized.

Copy link
Owner Author

@StanBright StanBright commented Sep 19, 2020

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

This comment has been minimized.

Copy link

@nitinsareen nitinsareen commented Sep 19, 2020

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.