正则表达式

基本正则表达式
基本正则表达式( 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

相关推荐
无忧.芙桃2 小时前
Linux系统编程(四):用户与权限管理
linux·运维·服务器
最强小杰3 小时前
某 OpenAI 兼容网关上的 `kimi-k3.1-pro`:Cline、Zed 接入与 SSE 排错示例
java·服务器·网络·ai
谙弆悕博士5 小时前
多智能体架构详解:层级树状架构(分级主从型)
运维·架构·大模型·agent·多智能体·langgraph·层级树状
千寻技术帮5 小时前
10454_基于Springboot的企业购销链管理系统
spring boot·mysql·vue·毕业设计·进销存
戊本菌5 小时前
进程(三)进程优先级:谁先上 CPU
linux·c语言·硬件架构
bksczm6 小时前
Redis Cluster 分片集群详解:槽路由、故障判定与扩缩容
数据库·redis·分布式
aningx6 小时前
Arch 系用 greetd 实现开机自动进 Plasma Wayland,注销自动回桌面
linux
观察员6 小时前
告别频繁锁屏:5行 PowerShell 脚本实现 Windows 自动防休眠
windows·命令行
张小姐的猫7 小时前
【基于 WebSocket 的多用户网页五子棋】—— 整合封装服务器模块设计实现2️⃣
服务器·websocket·网络协议
江无行者7 小时前
Linux 服务器 top 命令详解
linux