Skip to content

Commit 1443022

Browse files
linmingweijaywcjlove
authored andcommitted
Update grep.md (jaywcjlove#130)
add -P Perl regular expressions are nearly identical to Python regex
1 parent d77b977 commit 1443022

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

‎command/grep.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ grep
2828
-l --file-with-matches # 列出文件内容符合指定的范本样式的文件名称。
2929
-L --files-without-match # 列出文件内容不符合指定的范本样式的文件名称。
3030
-n --line-number # 在显示符合范本样式的那一列之前,标示出该列的编号。
31+
-P --perl-regexp # PATTERN 是一个 Perl 正则表达式
3132
-q --quiet或--silent # 不显示任何信息。
3233
-R/-r --recursive # 此参数的效果和指定“-d recurse”参数相同。
3334
-s --no-messages # 不显示错误信息。
@@ -95,6 +96,12 @@ grep -E "[1-9]+"
9596
# 或
9697
egrep "[1-9]+"
9798
```
99+
使用正则表达式 **-P** 选项:
100+
101+
```shell
102+
grep -P "(\d{3}\-){2}\d{4}" file_name
103+
```
104+
98105

99106
只输出文件中匹配到的部分 **-o** 选项:
100107

0 commit comments

Comments
 (0)