Skip to content

Instantly share code, notes, and snippets.

@arastu
Last active August 18, 2018 12:15
Show Gist options
  • Save arastu/4997147bf14d64c8dddc72fcab3e06c6 to your computer and use it in GitHub Desktop.
Save arastu/4997147bf14d64c8dddc72fcab3e06c6 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Googooli bash function for resolve a hostname to the first IP address or find your public ip address
# Example:
# $ ipof www.google.com
# 216.58.204.132
# find your public ip address when nothing is sent
# $ ipof
# x.x.x.x
function ipof() {
if [ -z "$1" ]
then
curl ipinfo.io/ip
else
dig +short $1 | awk '{ print ; exit }'
fi
}
@arastu
Copy link
Author

arastu commented Aug 18, 2018

Update:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment