当前位置:网站首页>grep 精确匹配
grep 精确匹配
2022-06-29 12:39:00 【51CTO】
使用grep实现精确过滤的五种方法
(1)当被过滤的内容占据一行时
[[email protected] scripts]# cat oldboy.log
200
0200
2000
[[email protected] scripts]# grep "\b200\b" oldboy.log
200 #<==正则按单词匹配
[[email protected] scripts]# grep -w "200" oldboy.log
200 #<==按单词匹配
[[email protected] scripts]# grep -x "200" oldboy.log
200 #<==按整行匹配
[[email protected] scripts]# grep "^200$" oldboy.log
200 #<==正则开头结尾匹配,相当于整行匹配
[[email protected] scripts]# grep -E "\<200\>" oldboy.log
200 #<==扩展正则
(2)当被过滤的内容占据一行的一部分
[[email protected] scripts]# cat oldboy.log
200 oldboy
0200 oldgirl
2000 littleboy
[[email protected] scripts]# grep "\b200\b" oldboy.log
200 oldboy
[[email protected] scripts]# grep -w "200" oldboy.log
200 oldboy
[[email protected] scripts]# grep -x "200" oldboy.log
#<==按整行匹配,所以没结果
[[email protected] scripts]# grep -x "200 oldboy" oldboy.log
200 oldboy
[[email protected] scripts]# grep "^200$" oldboy.log
#<==按整行匹配,所以没结果
[[email protected] scripts]# grep "^200 oldboy$" oldboy.log
200 oldboy
[[email protected] scripts]# grep -E "\<200\>" oldboy.log
200 oldboy
边栏推荐
- matplotlib的imshow函数显示灰度图像要设置vmin和vmax2个参数
- Cvpr2022 𞓜 future transformer with long-term action expectation
- Qitai observation: professional elites must step on the huge pit of entrepreneurship - learning effect pit
- C语言模拟实现所有字符函数
- PG Basics - logical structure management (1)
- 思科模拟器简单校园网设计,期末作业难度
- Cvpr2022 | reexamine pooling: your receptive field is not the best
- 【系统设计】邻近服务
- CVPR2022 | 可精简域适应
- 记一次 .NET 某物管后台服务 卡死分析
猜你喜欢

CVPR2022 | A ConvNet for the 2020s & 如何设计神经网络总结

CVPR2022 | 通过目标感知Transformer进行知识蒸馏

Openssl证书工具使用手册

从零搭建Pytorch模型教程(四)编写训练过程--参数解析

The imshow function of Matplotlib displays grayscale images. Vmin and vmax2 parameters should be set

技术分享| 融合调度中的广播功能设计

Uncover the secret! Pay attention to those machines under the membership system!

Qitai observation: professional elites must step on the huge pit of entrepreneurship - learning effect pit

Weserver publishing map service

Create an API rapid development platform, awesome!
随机推荐
GEE——美国LANDFIRE火灾数据集
RT thread memory management
CVPR2022 | PanopticDepth:深度感知全景分割的统一框架
WinDbg common commands
Getting started with mybaits (including example tutorial and source code)
安装terraform-ovirt插件为ovirt提供自动化管理
Tree array application (acwing 24224244)
What if the excel table exported from the repair record is too large?
koa2+better-sqlite3实现增删改查
Learn from the official motor and BLDC control strategies, and make money as soon as you learn
360数科新能源专项产品规模突破60亿
PG基础篇--逻辑结构管理(1)
Another "provincial capital university", coming!
sqlite3入门
记一次 .NET 某物管后台服务 卡死分析
[untitled] error in installation dependency: refusing to install package with name "* * *" under a package
Can I open an account online? Is it safe
The imshow function of Matplotlib displays grayscale images. Vmin and vmax2 parameters should be set
*Clock in algorithm *leetcode 146 Analysis of LRU cache algorithm
mysql调优