-1

我有以下输入文件(调用它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
4

1 回答 1

1

您给定的输入文件有 5 个匹配项而11:00不是 4 个匹配项,但没有匹配项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
于 2013-05-15T16:04:56.547 回答