Skip to main content
14 events
when toggle format what by license comment
Aug 31, 2022 at 8:33 history edited nisetama CC BY-SA 4.0
added 332 characters in body
Dec 20, 2020 at 16:19 history edited nisetama CC BY-SA 4.0
deleted 5 characters in body
Dec 20, 2020 at 16:07 history edited nisetama CC BY-SA 4.0
added 3 characters in body
Dec 20, 2020 at 15:55 history edited nisetama CC BY-SA 4.0
added 424 characters in body
Dec 20, 2020 at 11:50 history edited nisetama CC BY-SA 4.0
added 117 characters in body
Nov 14, 2020 at 13:46 comment added Grynn @LucianWischik - Good point! Probably better to fix this is a public gist, rather than comment stream ... but jq 'sort | .[(length/2) | floor] would work for odd length lists? Cannot think of a very compact way to handle even lists
Nov 12, 2020 at 18:14 comment added Lucian Wischik @Grynn That's not right for median. For an odd list echo '[1,2,3]' | jq 'sort | .[length/2]' your code gives the answer 'null', and for an even list echo '[1,2,3,4]' | jq 'sort | .[length/2]' your code picks the third element '3' but it should give the answer 2.5, the mean of the middle two elements.
Sep 24, 2020 at 20:14 comment added Grynn Extended a little: jq -s '{ min:min, max:max, sum:add, count:length, avg: (add/length), median: (sort | .[ length/2 ]) }' shows the output as an object with labels, pretty printed with colors!
Mar 29, 2018 at 15:50 history edited nisetama CC BY-SA 3.0
deleted 12 characters in body
Mar 29, 2018 at 15:42 history edited nisetama CC BY-SA 3.0
added 75 characters in body
Jul 19, 2017 at 21:16 comment added yodog beautiful! wish i could give +2
May 10, 2017 at 11:31 comment added jplindstrom The jq solution is worthy of a special mention, since it's succinct, and re-purposes the tool in a non-obvious way.
Dec 16, 2015 at 20:09 review Late answers
Dec 16, 2015 at 20:09
Dec 16, 2015 at 19:46 history answered nisetama CC BY-SA 3.0