Skip to content

Instantly share code, notes, and snippets.

@tonkla
Created March 13, 2017 05:38
Show Gist options
  • Save tonkla/20d08496bba238b2b66afd63b2a8a301 to your computer and use it in GitHub Desktop.
Save tonkla/20d08496bba238b2b66afd63b2a8a301 to your computer and use it in GitHub Desktop.
Batch WHOIS lookup
#!/bin/bash
if [ "$#" == "0" ]; then
echo "You need to supply at least one argument!"
exit 1
fi
DOMAINS=('.com' '.net' '.org')
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 For|has not been regi|No entri'
if [ $? -eq 0 ]; then
echo "$1${DOMAINS[${i}]} : available"
fi
done
shift
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment