Monday, January 03, 2011

Google Maps Hack for Bash Scripts

Here's a fun little hack. This lets you query Google maps from a bash shell script:
J="chicago"; \
K=`echo $J | sed "s/ /_/g"`; \
elinks --source http://maps.google.com/maps?q=$K | \
sed "s/}/\n/g" | grep "hnear\|latlng:" | \
sed -e "s/,+/+/g" -e "s/[,={\"]/\n/g" | \
grep "\+\|l..:[0-9\-]"

Chicago+Cook+Illinois
lat:41.878113999999997
lng:-87.629797999999994
Feed it "dakar" by setting $J, and you get:
Dakar+Region+Dakar+Senegal
lat:14.75
lng:-17.333333
What good is it? None, I'm sure.

1 comment:

  1. If i run this on a machine will this tell me the location?

    ReplyDelete