正则表达式

基本正则表达式
基本正则表达式( Basic Regular Expression , BRE ),又称为标准正则表达式,是最早制订的正则表达
式规范,仅支持最基本的元字符集。基本正则表达式是 POSIX 规范制订的两种正则表达式语法标准之
一,另外一种语法标准称为扩展正则表达式。

root@shell shell # grep ^a /etc/passwd
root@shell shell # grep h$ /etc/passwd
root@shell shell # grep . /etc/passwd
root@shell shell # grep ro* /etc/passwd
root@shell shell # grep "ro\{1,2\}" /etc/passwd
root@shell shell # grep "ro\{1\}" /etc/passwd
root@shell shell # grep a-zA-Z /etc/passwd
root@shell shell # grep a-Z /etc/passwd
root@shell shell # grep 0-9 /etc/passwd

root@shell shell\] # grep \[0-9a-Z\] /etc/passwd 或者 grep \[\[:alnum:\]

/etc/passwd
root@shell shell # grep \[:space:] /etc/passwd
root@shell shell # grep \^a /etc/passwd
root@shell shell # grep ^ab /etc/passwd
root@shell shell # grep "\." file
root@shell shell # grep "\(root\).*\1" file
root@shell shell # grep "ly\>" file
root@shell shell # grep "\<lo" file
root@shell shell # grep "\<love\>" file
love
root@shell shell # grep "\blove\b" file
love
扩展正则

root@shell shell # grep -E ro? /etc/passwd
root@shell shell # grep -E ro+ /etc/passwd
root@shell shell # grep -E "(root|adm|ssh)" /etc/passwd

相关推荐
Databend15 小时前
在 AWS 中国峰会逛了一天,我在 Databend 展台看到了 Agent 数据基础设施的新思路
数据库·人工智能·agent
Web3探索者2 天前
可视化服务器管理和传统命令行区别是什么?新手教程:Linux 运维到底该用图形界面还是 SSH 命令行?
linux·ssh
李白客2 天前
KES新版MySQL兼容能力再升级意味着什么?
mysql·国产数据库
zylyehuo2 天前
Linux系统中网线与USB网络共享冲突
linux
ClouGence2 天前
Oracle 数据同步为什么会出现数据不一致?长事务是常被忽略的原因
数据库·后端·oracle
荣--2 天前
一键部署不是为了省时间 —— 它是把"买来的 PaaS"变成"自己的平台"的拐点
运维·zabbix·工程化·一键部署·平台化·边界设计
江华森2 天前
动手实战学 Docker — 从零到集群编排完全指南
运维
飞将2 天前
从零实现数据库(2)——HashIndex + IndexManager
数据库
Avan_菜菜3 天前
FRP 内网穿透完整实战:从 HTTP 映射到 HTTPS 自签代理
运维·nginx·https
Nturmoils3 天前
订单列表慢查询,先看 WHERE、ORDER BY 和 LIMIT
数据库