I'm a beginner and I'm trying to make a bash script that downloads data from a website and tells me hourly prices of a service and tells me when it is cheap and when it is expensive.
curl -s https://something.json | jq '.tomorrow[] | select(.region=="region3") | {values, median}'
From that command I get this:
{
"values": [
71.65,
70.76,
70.63,
71.43,
73.47,
84.35,
88.18,
97.98,
112.65,
155.36,
155.32,
207.12,
252.48,
311.12,
350.38,
452.02,
461.86,
503.09,
487.77,
465.18,
401.17,
335.88,
298.53,
255.61
],
"median": 243.08
}
and I want to check each value compared to the median and print out something like
At 1am it is cheap
...
At 5pm it is expensive
...
At 11pm it is cheap
...
I tried this, but it didn't work
curl -s https://something.json | jq '.tomorrow[] | select(.region=="region3") | {values, median} | if .values >= .median then "Expensive" elif .values <= .median then "Cheap"'
I thought about using walk() aswell but couldn't quite figure it out.