where am i ? ( a bash oneliner to get GPS location and Street Address using Google Maps )

Reposted from FOSS BOSS. All credits to Kamal.


/bin/echo '{"version": "1.1.0","host": "maps.google.com","request_address": true,"address_language": "en_GB", "wifi_towers": [{"mac_address": "' $( iwlist wlan0 scan | grep Address | head -1 | awk '{print $5}' | sed -e 's/ //g' ) '","signal_strength": 8,"age": 0}]}' | sed -e 's/" /"/' -e 's/ "/"/g' > /tmp/post.$$ && curl -X POST -d @/tmp/post.$$ http://www.google.com/loc/json | sed -e 's/{/\n/g' -e 's/,/\n/g'

BASH: Prepend A Text / Lines To a File

Using a temporary file:

echo ‘line 1′ > /tmp/newfile
echo ‘line 2′ >> /tmp/newfile
cat yourfile >> /tmp/newfile
cp /tmp/newfile yourfile

A One-Liner:

echo “text”|cat – yourfile > /tmp/out && mv /tmp/out yourfile

Stats

  • 142,056 Hits and counting...

Archives

Follow

Get every new post delivered to your Inbox.