CvH
chewitt
I'm trying to adjust my script for the coming new server structure:
https://test3.libreelec.tv/11.0/Generic/
I now want to avoide some shortages/mistakes [*] of my old script, where I were unable to exactly get what's an update/downgrade.
so the new script version should work with the field "mtime" (see attached file, it's pre-filtered output from command: curl -s https://test3.libreelec.tv/json/11.0/Generic/)
to be able to compare the mtime fields I need to convert the date/time string to a form allowing to do integer comparison
this should be the target format : 202207020834. (CCYYMMDDHHMM)
my first draft is
- to create a temporary list of only the mtime strings
- read the list and convert the mtime string to the above target format
- do the comparsions
- notice the next nightly what is elder/newer then the running one
- (unsure) convert back to the mtime string and grep that mtime string in the list ...
- download the found nightly and it's sha256 (unsure if needed, cause -AFAIK- the update installer does already a check summing)
...
the problem now are:
a) read the above temporary file containing the mtime strings for conversion *without* stumbling over blanks the strings contain
my attempt to fix: set IFS="
or as I now see via CvH suggestion
b) doing so I 'll up to now get a additional date, cause -my guess - bash read commands from the right to left, so I get one more date (the current date) then mtime strings are in file
How to avoid that ???
[*]
the "build date-git hash", form 20220623-a81b6d9 doesn't in all cases allow to figure the correct nightly for update/downgrade.
thinks of builds with same date and different git hash, e.g. builds from 5:00 and 19:00
converted mtime string seems the way to go and saves me a lot of logical brainer's to get it better as in my current script V0.08
===
other question:
is there a way to do an inline conversations during an output of awk ?
let say, I've a file named out-von-JSON containing this:
{ "name":"LibreELEC-Generic.x86_64-11.0-nightly-20220628-f7f28a7.img.gz", "type":"file", "mtime":"Tue, 28 Jun 2022 18:07:28 GMT", "size":221226619 },
to get the mtime string field I would do the following:
cat out-von-JSON|grep -v sha256 | grep -v Generic.x|awk -F '"mtime":' '{print $2}'|cut -d '"' -f2
=> Tue, 28 Jun 2022 18:07:28 GMT
Am I able to do inline conversation for the awk part '{print $2}' ?
- it's 30 years ago I learned Unix -