#!/bin/sh # geoip: Locate an IP address in the world. Requires `jq`. API="http://ip-api.com/json" if [ "$#" -ne 1 ] || echo "$1" | grep -qvxP "(\d{1,3}\.){3}\d{1,3}"; then echo "please provide a valid IP address" >&2 exit 1 fi curl -s "$API/$1" | jq '{ ip: .query, isp: .isp, org: .org, country: .country, regionName: .regionName, city: .city, zip: .zip, lat: .lat, lon: .lon, timezone: .timezone, }'