I have an Android phone (not an emulator) and I'd like to make a bash script that sets the location of the phone. If I have a file that contains my latitude and longitudes like this
45.3453 13.3453
45.3467 13.3501
etc etc
I want to do something like
#!/bin/bash
for ii in $(cat lat_lon_file); do
lat=$(echo $ii | cut -f 1)
lon=$(echo $ii | cut -f 2)
adb shell setLatLon $lat $lon
done
I'm not sure how I can set locations like this (if at all), is there something I can echo in /proc somewhere?
Also, bonus: is there a cleaner way to cut
$ii
in my script than echo
ing and piping?
Your current script does not iterate over lines, it iterates over words. This means that each iteration will only have the latitude or the longitude. This correct way to iterate over lines in a file and answers your side question:
while read -r lat lon _; do
adb shell setLatLon "$lat" "$lon"
done < lat_lon_file
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.