Last active
August 29, 2015 14:22
-
-
Save korkey128k/5b207ec04aba2c21bee6 to your computer and use it in GitHub Desktop.
Return where a website is hosted, pass -m for mail
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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