Last active
August 29, 2015 14:24
-
-
Save josephok/99448b5c408de920c6f4 to your computer and use it in GitHub Desktop.
Get my ip location
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 | |
ipsource=$(curl -s www.123cha.com | grep "您的ip") | |
ip=$(echo $ipsource | grep -oP "\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}" | head -1) | |
location=$(echo $ipsource | grep -o "来自: .*++" | sed -e 's/来自: //g' -e 's/ /-/g' -e 's/-++//g') | |
echo "$ip $location" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment