Skip to content

Instantly share code, notes, and snippets.

@ahmadawais
Created October 21, 2019 19:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ahmadawais/56261539c39a9f66c762989b14c510a4 to your computer and use it in GitHub Desktop.
Save ahmadawais/56261539c39a9f66c762989b14c510a4 to your computer and use it in GitHub Desktop.
Check the whois of a domain from the command line.
# Check the whois of a domain or form a URL.
# @usage: whois google.com
# @usage: whois https://google.com
function whois() {
local domain=$(echo "$1" | awk -F/ '{print $3}') # get domain from URL
if [ -z $domain ] ; then
domain=$1
fi
echo "Getting whois record for: $domain …"
# Avoid recursion
# This is the best whois server AFAIK.
# Strip extra fluff
/usr/bin/whois -h whois.internic.net $domain | sed '/NOTICE:/q'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment