计算多个日志文件中的行数,按日期过滤,以文件名输出

问题描述

我需要计算多个日志文件 (/var/log/) 中的行数,按日期过滤 (07/Apr/2021:11),并使用文件显示输出

Expected output:
- file1.log: 25 matched lines
- file2.log: 36 matched lines
- file3.log: 56 matched lines

我用“wc -l”计算它,我用grep -R path“07/Apr/2021:11”按日期过滤它... 现在我想合并所有以显示输出,如“文件名:匹配行”

非常感谢。

解决方法

grep -c "07/Apr/2021:11" /var/log/*