当前位置:网站首页>【不积跬步无以至千里】统计日志指定时间段内的关键词
【不积跬步无以至千里】统计日志指定时间段内的关键词
2022-07-26 22:26:00 【GottdesKrieges】
问题背景
统计日志文件中,上午8点到中午12点之间,关键字出现的行数。
解决办法
步骤1:获取开始和结尾时间点所在的行号
[[email protected] ~]# grep -n '08:00' testme.log
5:2022 08:00:00 ldndsnkdalm keyword mlsmls ,lsmsns,
[[email protected] ~]#
[[email protected] ~]# grep -n '12:00' testme.log
20:2022 12:00:00 ldndsnkdalm keyword mlsmls ,lsmsns, keyword
步骤2:截取对应时间段的日志
[[email protected] ~]# sed -n '5,20p' testme.log > testme-001.log
步骤3:统计关键字出现的行数
[[email protected] ~]# grep -c 'keyword' testme-001.log
14
[[email protected] ~]#
[[email protected] ~]# cat testme-001.log | grep keyword | wc -l
14
边栏推荐
- Go uses flag package to parse command line parameters
- Arduino experiment I: two color lamp experiment
- Typescript notes
- MySQL syntax uses detailed code version
- Cheaper than seals, with a large space for shape explosion. Is there really no match for 200000 or so? Chang'an's new "King fried" is cost-effective
- What if redis memory is full? This is the right way to deal with it
- App information reconnaissance & night God simulator burp packet capture configuration
- Basic use of gateway
- HCIA-R&S自用笔记(19)VLAN配置及实验、VLAN间路由
- What is the reason for oom during redis shake synchronization in shake database?
猜你喜欢

Basic use of gateway

Real time voice quality monitoring

How to recover the original data when the U disk is damaged, and how to recover the damaged data when the U disk is damaged

json格式化小工具--pyqt5实例

第二部分—C语言提高篇_9. 链表

第二部分—C语言提高篇_12. 动/精态库的封装和使用

关于 StatefulWidget,你不得不知道的原理和要点!

gateway基本使用

MySQL random paging to get non duplicate data

How to use data pipeline to realize test modernization
随机推荐
Part II - C language improvement_ 10. Function pointer and callback function
8-其他编程语言--记录
What is Base64?
The memory occupation of the computer is too high after it is turned on (more than 50%)
Part II - C language improvement_ 8. File operation
KT6368A蓝牙芯片开发注意事项以及问题集锦--长期更新
[postgresql]postgresqlg use generate_ Series() function completes statistics
企业数据治理面临的六大挑战!
Practical project: boost search engine
基本的SELECT语句
Vector execution engine framework gluten announced the official open source and appeared at spark technology summit
New employees of black maredge takeout
Security team: Recently, there is an rce vulnerability in the COREMAIL email client of windows, which may lead to the disclosure of the private key of the wallet
华测RTK采集的GPX数据如何带属性转出kml、shp进行后续的管理和分析
[Luogu] p1395 meeting
MySQL syntax uses detailed code version
Basic select statement
HCIA-R&S自用笔记(19)VLAN配置及实验、VLAN间路由
Pre research of data quality management tools Griffin vs deequ vs great expectations vs quality
The interviewer asked: this point of JS