我有消息日志文件,每行代表一个 cdr 或事务,如下所示:
2019-03-14 13:58:16,260 DEBUG xxxxxxxxxxxxxxxxxxxxxxxxx
我必须计算每秒的交易量。这意味着每秒的 cdrs(行)数,并生成包含时间和事务数(行)的报告,如下所示:
Time TPS
2019-03-14 13:58:16 102
答案1
printf -- " Time TPS\n"
sed 's/,.*//' < inputfile | # extract just the date-time
sort |
uniq -c | # field 1 is now the count of each line's occurrences
awk '{ print $2, $3, $1 }' # rewrite as "date time count"