I've got a text file from which I'd like to extract some lines and phrases. I'd also like to insert a couple of characters in some spots. It's a file I intend to download periodically over the course of the day, one with certain values that change throughout the course of the day: the file is a simple description of weather conditions, giving things like current time, temperature, humidity and so forth. Most of the text in the file is not of interest and I'm trying to find a way to get from it just the text I'm interested in. I grab the file using curl and I'd like to pipe it through some command(s) that will extract only the needed parts and insert the characters mentioned.
The content of the text file I grab looks a lot like this:
Smyrna, Smyrna Airport, TN, United States (KMQY) 36-00-32N 086-31-12W Aug 09, 2016 - 10:56 AM EDT / 2016.08.09 1456 UTC Visibility: 10 mile(s):0 Sky conditions: partly cloudy Temperature: 86 F (30 C) Heat index: 93.4 F (34.1 C):1 Dew Point: 73 F (23 C) Relative Humidity: 66% Pressure (altimeter): 30.01 in. Hg (1016 hPa) ob: KMQY 091456Z 18006 10SM SCT035 30/23 A3001 cycle: 15
Of those lines, only 2, 4, 5, and 8 contain text of interest--the other lines can just be discarded. Furthermore, a lot of what's in the target lines is not needed as well. It should be remarked that the content of this file will be somewhat fluid, with variables like time, temperature and humidity changing at regular intervals. I'd like the finished product, after uneeded material has been eliminated, to look as follows:
'Aug 09, 2016 - 10:56 AM EDT\nconditions: partly cloudy\n86 F\nHumidity: 66%'
Note the inserted characters-- \ n and ' (inverted commas at the beginning and end)--characters that need to be inserted to indicate line breaks and that the entire line, including spaces, is to be included, to the program to which I'll be feeding this output (imagemagick). Preferably, I'd like to be able to pipe the output from curl to some command or series of commands that will extract that target material, insert the inverted commas and \n sequences, then write that to a file. So, something like
curl http://my.weat.her/local.txt | command(s) > currentcond.txt
Anyone have suggestions for accomplishing this task?