linux_shell_类似sql的orderby 取最大值

时间:2021-05-15 15:11:24
{"time":"2015.08.14 21:45:13","total":999224516}
{"time":"2015.08.14 21:45:24","total":999225424}
{"time":"2015.08.14 21:45:34","total":999226141}
{"time":"2015.08.14 21:45:47","total":999227249}
{"time":"2015.08.14 21:45:57","total":999228051}
{"time":"2015.08.14 21:50:08","total":999247950}
{"time":"2015.08.14 21:50:34","total":999249978}
{"time":"2015.08.14 21:50:58","total":999251893}
{"time":"2015.08.14 21:55:14","total":999271885}
{"time":"2015.08.14 21:55:26","total":999272904}

需求场景 ,通过shell 筛选 每分钟的最大一条输出(最后一条) :

awk -F'","' 'BEGIN{line=""}{pre=substr(line,10,16);a=substr($1,10,16);if(line != "" && pre!=a){print line}line=$0}' 5.info | head