#! /bin/zsh # # this file: # https://dataswamp.org/~incal/distance/loc # # This program takes one argument which is a name of a city, # island, etc. # # It outputs the position as latitude and longitude, e.g.: # # $ loc Uppsala # 59.85806 17.64472 # # The name can contain whitespace: # # $ loc Easter Island # 27.117 109.367 # # Note: decimalized system, no minutes. local args=$(echo $* | sed 's/ /%20/g') local base_url=https://en.wikipedia.org/w/index.php local url=${base_url}\?title=${args}\&printable=yes local coords="$(curl -s $url | grep -o '"geo">[-.[:digit:]]*; [-.[:digit:]]*<' | head -n 1 | sed 's/\("geo">\|-\|;\|<\)//g')" echo $coords