Skip to content

Instantly share code, notes, and snippets.

@smmtaheri
Forked from arastu/ipof.sh
Last active August 18, 2018 12:03
Show Gist options
  • Save smmtaheri/dc5574642da2daff32d6c4c4f1bde661 to your computer and use it in GitHub Desktop.
Save smmtaheri/dc5574642da2daff32d6c4c4f1bde661 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
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment