正则表达式

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

相关推荐
光电笑映6 小时前
网络通信基础:从协议分层到 Socket 编程预备
linux·运维·服务器·网络
酸菜。6 小时前
dw_apb_gpio总结
linux
wunaiqiezixin6 小时前
MIT 6.S081 file system 实验篇(lab9):Large files (moderate)
linux·unix·os·xv6·mit6.s081
泡泡鱼(敲代码中)7 小时前
MySQL 学习笔记:DCL、函数与约束 —— 安全、效率、完整性的三板斧
开发语言·笔记·sql·学习·mysql·gitee
YCOSA20257 小时前
BUG修复---雨晨 Windows 11 IoT 企业版 LTSC 23H2 终结版 22631.7588
windows·物联网
GeW7 小时前
RHCE 考试通过率提升:核心考点、实验环境与排错技巧
linux
微小冷7 小时前
用Mermaid画时序图
运维·流程图·时序图·mermaid·生命线
ayaya_mana7 小时前
Qwen3.5-9B融合DeepSeek-V4-Flash小模型实测与部署
windows·本地大模型·qwen3.5
其实防守也摸鱼7 小时前
Codex 下载与本地部署实战:从安装到运行全指南
android·大数据·运维·安全·自动化
wdfk_prog7 小时前
ROS教程07:从 ros::start() 顺着源码读懂 Master、XML-RPC 与 Topic 注册发现
运维·缓存·docker·容器·ros