I am new to shell scripting and would appreciate some help.
First some background - I want to display picture showing hosts around the world that have accessed a specific file on a server. All that is logged about the hosts is IP address - which is fine. From these IP addresses I can get a general idea of their location - again fine - via http://api.hostip.info/
(a geolocator). Basically, this is to provide a quick visual. It doesn't need to be extremely detailed.
Now, the first part I can handle - converting IP address to Latitude/Longitude. This is done via the following script:
for line in $(< hosts);do
lynx -dump "http://api.hostip.info/rough.php?ip=$line&position=true" >> output.txt
This outputs a file with the following format
Country Code: FR
Country: UNITED STATES
Country Code: US
City: Bridgeport, CT
This is where I am stuck. The only data I need from this format is the latitudes and the longitudes. Each lat/long pair needs to be on its own line. Example:
My question is: How do I pull just the latitude and longitude from output.txt and put them in the above format?