[HTC Rezound] Neo:
Challenge Accepted?

I want to write a linux script that will insert 9 lines within a simple file without opening a text editor.

3 of those lines to be added in will have to be based upon information listed in another file within that same directory.

For example:

The file I want to change is called api

In api near the bottom, there is information like this:

{
"url": "http://vp-zp.com/snuzzo/roms/flyhalf205/cm10.2/vigor/cm-10.2-20130917-UNOFFICIAL-neo-vigor.zip",
"timestamp": "1377586616",
"md5sum": "44e8c61279044b8f5413ce950b27a384",
"api_level": "18",
"filename": "cm-10.2-20130917-UNOFFICIAL-neo-vigor.zip",
"changes": "http://vp-zp.com/snuzzo/roms/flyhalf205/changes.txt",
"channel": "nightly"
},
{
"url": "http://vp-zp.com/snuzzo/roms/flyhalf205/cm10.2/vigor/cm-10.2-20131004-UNOFFICIAL-vigor.zip",
"timestamp": "1377586617",
"md5sum": "9c8f093d00240827a1cc776573376bc0",
"api_level": "18",
"filename": "cm-10.2-20131004-UNOFFICIAL-vigor.zip",
"changes": "http://vp-zp.com/snuzzo/roms/flyhalf205/changes.txt",
"channel": "nightly"
},
],
"error": null
}

In the same folder where api will be, the other file to be providing information is:

cm-10.2-20131009-UNOFFICIAL-vigor.md5

seeing as how the name of this .md5 file will always change, the script designed will need to know to look for a file ending in .md5 instead of the actual file name.

within that md5 file, only the following line is printed:

c188eabe733b25e8a22bef94b5e30417 cm-10.2-20131009-UNOFFICIAL-vigor.zip

So the script I want needs to do the following:

I want it to start new lines where “],” is listed 3rd line from the bottom of api file, and have it pushed down to insert new lines so the script will need to search for that bracket each time as the line number through every rom release will always change.

1) The first of the 9 lines I want listed will be the open bracket:

“{“

(2) The next line will need to follow information listed within the md5 file.

ie:

"url": "http://vp-zp.com/snuzzo/roms/flyhalf205/cm10.2/vigor/name-of-zip-file-listed-at-second-part-in-md5-file",

(3) The next line will be the timestamp which will somehow need to be 1 digit higher than the previous timestamp as exampled above. for this example, it would like as follows:

1377586618

(4) The next line will need to follow this same print listed in the example only the information for the md5sum digits will need to be pulled from the md5 file.

ie:

"md5sum": "numeric-digits-listed-in-md5-file",

(5) The next line will simply remain the same as:

"api_level": "18",

(6) The next line will need to be exactly what we did earlier for the second line to display the .zip file which is defined in md5

ie:

"filename": "name-of-zip-file-listed-at-second-part-in-md5-file",

(7-9) The last 3 lines will print as follows:

"changes": "http://vp-zp.com/snuzzo/roms/flyhalf205/changes.txt",
"channel": "nightly"
},

I greatly appreciate any help a code/script master out there can provide.

This will allow me to never have to worry about modifying our api manually whenever I run an auto nightly. Granted it only takes a few minutes to do it, it takes the "auto work" out of building nightlies and requires me to remember to make the change and upload it so that your phones can register an update.

Thanks!

-Neo