Here's a fun little script using the Google Maps Geocoding API:


[pete@server1 ~]# cat latlong.sh
#!/bin/bash

if [[ -z $@ ]]; then 
  echo "Works better with an address..."
  exit 1
fi
if [[ ! -x /usr/bin/curl ]]; then 
  echo "ERROR: Can't work without /usr/bin/curl"
  exit 1
fi
if [ ! -x /usr/bin/xml2 ]; then 
  echo "ERROR: Please install package xml2 from the EPEL repo first."
  exit 1
fi

address="$(echo $@ | sed 's/ /+/g')"

curl -s "http://maps.googleapis.com/maps/api/geocode/xml?address=${address}" \
     -o /tmp/file.xml

eval $(xml2 < /tmp/file.xml | tr '/, ' '___' | grep =)

if [[ $_GeocodeResponse_status == "OK" ]]; then
  echo "Address: $(echo $address | sed 's/+/ /g')"
  echo "Lattitude: $_GeocodeResponse_result_geometry_location_lat"
  echo "Longitude: $_GeocodeResponse_result_geometry_location_lng"
else
  echo "No results"
fi

exit 0

[pete@server1 ~]# ./latlong.sh 1600 Pennsylvania Ave, Washington, DC
Address: 1600 Pennsylvania Ave, Washington, DC
Lattitude: 38.8791981
Longitude: -76.9818437
[pete@server1 ~]#


Awesome!