我有以下输入文件(称之为log
)。
2012-02-10 11:00:44.211 connection closed_to host
2012-02-10 11:00:44.598 connection closed_to host
2012-02-10 11:00:45.510 connection closed_to host
2012-02-10 11:00:45.891 connection closed_to host
2012-02-10 11:00:46.111 connection closed_to host
我希望能够计算每分钟的行数。例如,我想获得以下输出:
2012-02-10 11:00 connection closed to host 5
答案 0 :(得分:1)
您的输入文件在11:00
而不是4时有5个匹配,11:01
没有匹配但忽略了:
awk -F'[: ]' '{a[$1" "$2":"$3" "$5" "$6" "$7]++}END{for(k in a)print k,a[k]}' log
2012-02-10 11:00 connection closed_to host 5