Skip to content

Instantly share code, notes, and snippets.

@FrenchTechLead
Last active March 27, 2021 12:55
Show Gist options
  • Save FrenchTechLead/7566cb6c954675bd369d3c8f1480fc52 to your computer and use it in GitHub Desktop.
Save FrenchTechLead/7566cb6c954675bd369d3c8f1480fc52 to your computer and use it in GitHub Desktop.
This script checks for the availability of a domain name.
#!/bin/bash
if [ "$#" == "0" ];
then
echo "You need tu supply at least one argument!"
exit 1
fi
DOMAINS=( '.com' '.org' '.fr')
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
tput setaf 2;
echo "$1${DOMAINS[${i}]} : available"
else
tput setaf 1;
echo "$1${DOMAINS[${i}]} : not available"
fi
tput setaf 0;
done
shift
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment