请教各位高手一个shell
数据
2013-05-08 11:11:44 [com.interceptor.DynamicDataSourceInterceptor]-[ERROR] accessurl: http://
2013-05-08 11:11:44 [com.interceptor.DynamicDataSourceInterceptor]-[ERROR] accessurl: http://
2013-05-08 11:11:44 [com.interceptor.DynamicDataSourceInterceptor]-[ERROR] accessurl: http://
2013-05-08 11:11:44 [com.interceptor.DynamicDataSourceInterceptor]-[ERROR] accessurl: http://
2013-05-08 11:11:44 [com.interceptor.DynamicDataSourceInterceptor]-[ERROR] accessurl: http://
2013-05-08 11:11:44 [com.interceptor.DynamicDataSourceInterceptor]-[ERROR] accessurl: http://
2013-05-08 11:11:44 [com.interceptor.DynamicDataSourceInterceptor]-[ERROR] accessurl: http://
2013-05-08 11:11:44 [com.interceptor.DynamicDataSourceInterceptor]-[ERROR] accessurl: http://
2013-05-08 11:11:44 [com.interceptor.DynamicDataSourceInterceptor]-[ERROR] accessurl: http://
2013-05-08 11:11:45 [com.interceptor.DynamicDataSourceInterceptor]-[ERROR] accessurl: http://
2013-05-08 11:11:45 [com.interceptor.DynamicDataSourceInterceptor]-[ERROR] accessurl: http://
2013-05-08 11:11:45 [com.interceptor.DynamicDataSourceInterceptor]-[ERROR] accessurl: http://
2013-05-08 11:11:45 [com.interceptor.DynamicDataSourceInterceptor]-[ERROR] accessurl: http://
我需要的结果是这样的
2013-05-08 11:11:44 9
2013-05-08 11:11:45 4
也就是按时间分组,输出个数
------解决方案--------------------没问题啊,你的问题也可以这样解决
awk -F"[" '{a[$1]+=1}END{for(i in a) print i,a[i]}'
------解决方案--------------------
在awk之前先sort一把就可以了吧
------解决方案--------------------$ awk '{a[$1" "$2]++}END{for(i in a)print i,a[i]}' 1.txt
------解决方案--------------------给你另一个方法,丰富一下:cut -d ' ' -f 1-2 data.txt
------解决方案-------------------- uniq -c