当前位置:网站首页>【不积跬步无以至千里】统计日志指定时间段内的关键词
【不积跬步无以至千里】统计日志指定时间段内的关键词
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
边栏推荐
- About statefulwidget, you have to know the principle and main points!
- Part II - C language improvement_ 7. Structure
- pgsql -> flink cdc -> flink -> Mysql, if a PgSQL CDC
- 上千Tile的倾斜模型浏览提速,告别一块一块往外蹦的尴尬
- 沟通中经常用到的几个库存术语
- SQL Basics
- [MySQL] CentOS 7.9 installation and use mysql-5.7.39 binary version
- Kingbasees SQL language reference manual of Jincang database (3.1.1.14. scope type)
- Silicon Valley class lesson 5 - Tencent cloud object storage and course classification management
- 实战项目:Boost搜索引擎
猜你喜欢

Pyqt5 how to set pushbutton click event to obtain file address

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

Reinforcement learning weekly 55: lb-sgd, msp-drl & robust reinforcement learning against

为什么我还在CSDN写文章?一段陪伴学习的历程。

Arduino experiment I: two color lamp experiment

公有云安全性和合规性方面的考虑事项

2. Realize the map of navigation bar and battle page

Customer case | student education relies on observation cloud to create a new ecosystem of observable Smart Education

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

Basic use of gateway
随机推荐
第二部分—C语言提高篇_13. 递归函数
[shaders realize distorted outline effect _shader effect Chapter 2]
Hcia-r & s self use notes (21) STP technical background, STP foundation and data package structure, STP election rules and cases
How can enterprises mitigate the security risks of Internet of things and industrial Internet of things
Go uses flag package to parse command line parameters
电脑开机后内存占用过高(50%以上)
Part II - C language improvement_ 8. File operation
华测RTK采集的GPX数据如何带属性转出kml、shp进行后续的管理和分析
[H5 bottom scrolling paging loading]
[Luogu] p2709 little B's inquiry
Part II - C language improvement_ 9. Linked list
Part II - C language improvement_ 5. Bit operation
Vector execution engine framework gluten announced the official open source and appeared at spark technology summit
实战项目:Boost搜索引擎
1. Configuration environment and project creation
Differences between PHP round and sprintf functions
30、 Modern storage system (management database and distributed storage system)
Do you know the common core types of magnetic ring inductors?
Product principles of non-financial decentralized application
Kt6368a Bluetooth chip development precautions and problem collection - long term update