Last active
September 14, 2015 18:35
-
-
Save liddiard/912a4f3205e63d608873 to your computer and use it in GitHub Desktop.
Bash script to show the current location of the machine you're running on using GeoIP in the format: "City, State, Country".
This file contains hidden or 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
#!/bin/bash | |
API_URL="http://freegeoip.net/csv/" | |
# Get current external IP (http://askubuntu.com/a/95911) | |
IP=$(curl -s checkip.dyndns.org | sed -e 's/.*Current IP Address: //' -e 's/<.*$//') | |
LOCATION=$(curl -s ${API_URL}${IP}) | |
echo "$LOCATION" | awk -F "," '{print $6 ",", $5 ",", $3}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment