Skip to content

Instantly share code, notes, and snippets.

@josephok
Last active August 29, 2015 14:24
Show Gist options
  • Save josephok/99448b5c408de920c6f4 to your computer and use it in GitHub Desktop.
Save josephok/99448b5c408de920c6f4 to your computer and use it in GitHub Desktop.
Get my ip location
#!/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