Shell-perl兼容正则

perl兼容正则符号

正则符号 描述
 匹配单调边界
w 匹配字符数字下划线
W 和w相反
s 匹配空白
d 匹配数字
d+ 匹配多个数字
D 匹配非数字
点击查看代码
1.匹配字符数字下划线
grep -P "w" /etc/passwd

2.匹配符号
grep -P "W" /etc/passwd

3.匹配空白
grep -P "s" /etc/passwd

4.匹配数字
grep -P "d" /etc/passwd

5.匹配bin,不包括sbin
grep -P "root" /etc/passwd
原文地址:https://www.cnblogs.com/fxxy/p/15424924.html