2011-03-22 00:00:39 2.49
2011-03-22 00:12:39 6
2011-03-22 00:24:39 2.22
2011-03-22 00:36:39 5.21
2011-03-22 00:48:39 2.02
2011-03-22 01:00:39 2.74
2011-03-22 01:12:39 4.71
2011-03-22 01:24:39 3.26
2011-03-22 01:36:39 3.93
2011-03-22 01:48:39 2.24
2011-03-22 02:00:39 1.5
2011-03-22 02:12:39 5.04
2011-03-22 02:24:39 1.25
2011-03-22 02:36:39 2.24
2011-03-22 02:48:39 2.96
2011-03-22 03:00:39 1.25
2011-03-22 03:12:39 3.74
2011-03-22 03:24:39 1.75
2011-03-22 03:36:39 1.75
求半小时内的最大值,e.g
希望取到 00:00:00 到 00:29:59 的最大值 6
希望取到 00:30:00 到 00:59:59 的最大值 5.21
- awk -F '[ :]+' '{k=sprintf(($3<30)?"%s %s:00:00~%s:29:59":"%s %s:30:00~%s:59:59",$1,$2,$2);a[k]=(a[k]<$5)?$5:a[k];}END{for(i in a)printf "%s\t%s\n",i,a[i]}' data|sort
再来一个:
awk -F '[- :]+' '{n=$4*60+$5;a[$1"-"$2"-"$3","int(n/5)]++}END{for (i in a) {split(i,m,",");print m[1],m[2]*5+1"-"(m[2]+1)*5"(分钟)",a[i]}}' <<<"2011-04-24 00:00:00
2011-04-24 00:00:01
2011-04-24 00:00:01
2011-04-24 00:00:02
2011-04-24 00:00:03
2011-04-24 00:00:03
2011-04-24 00:00:05
2011-04-24 00:00:05
2011-04-24 00:00:05
2011-04-24 00:00:10"
2011-04-24 1-5(分钟) 10
阅读(1879) | 评论(0) | 转发(0) |