Skip to content

Instantly share code, notes, and snippets.

@korkey128k
Last active August 29, 2015 14:22
Show Gist options
  • Save korkey128k/5b207ec04aba2c21bee6 to your computer and use it in GitHub Desktop.
Save korkey128k/5b207ec04aba2c21bee6 to your computer and use it in GitHub Desktop.
Return where a website is hosted, pass -m for mail
function double_host {
function lookup {
host $1 | grep 'has address' | host `awk {'print $4'}` | awk {'print $5'} | sed -e 's/[.]$//'
}
NUMARGS=$#
if [ $NUMARGS -eq 1 ]; then
echo "A Record"
lookup $1
else
if [ "$1" = "-m" ]; then
echo "Mail Address"
lookup $(host $2 | grep 'is handled' | host `awk {'print $7'}`)
else
echo "Invalid option: $1" >&2
fi
fi
}
alias whereis=double_host
# whereis example.com
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment