grep: sync translations with English pages (#22194)

This commit is contained in:
Ninzero
2026-04-25 15:52:14 +08:00
committed by GitHub
parent 85ff73b858
commit db1af50e77
2 changed files with 30 additions and 30 deletions
+13 -13
View File
@@ -1,37 +1,37 @@
# grep
> 使用`regex`式查找文件中的模式。
> 使用 `regex` 式查找文件中的模式。
> 另请参阅:`regex`。
> 更多信息:<https://www.gnu.org/software/grep/manual/grep.html>。
- 在文件中查找模式:
`grep "{{模式字符串}}" {{路径/到/文件}}`
`grep "{{模式字符串}}" {{路径/到/文件1 路径/到/文件2}}`
- 在文件中精确地查找字符串(禁用`regex`式):
- 查找精确的字符串(禁用 `regex` 式):
`grep {{[-F|--fixed-strings]}} "{{字符串}}" {{路径/到/文件}}`
-指定目录下的所有文件中递归地查找模式,显示匹配的行号并忽略二进制文件:
-目录中递归查找所有文件中的模式,忽略二进制文件:
`grep {{[-rnI|--recursive --line-number --binary-files=without-match]}} "{{模式字符串}}" {{路径/到/目录}}`
`grep {{[-rI|--recursive --binary-files=without-match]}} "{{模式字符串}}" {{路径/到/目录}}`
- 使用大小写不敏感的扩展`regex`式(支持 `?``+``{}``()`, 和 `|`
`grep {{[-Ei|--extended-regexp --ignore-case]}} "{{模式字符串}}" {{路径/到/文件}}`
- 在每个匹配前后、之前或之后打印 3 行上下文:
- 打印每个匹配项周围、之前或之后的 3 行上下文
`grep {{--context|--before-context|--after-context}} 3 "{{模式字符串}}" {{路径/到/文件}}`
- 以带有颜色的方式,打印每个匹配的文件名和行号:
- 打印每个匹配的文件名和行号,并带彩色输出
`grep {{[-Hn|--with-filename --line-number]}} --color=always "{{模式字符串}}" {{路径/到/文件}}`
- 打印文件中与模式匹配的
- 打印匹配的文本
`grep {{[-o|--only-matching]}} "{{模式字符串}}" {{路径/到/文件}}`
-`stdin`(标准输入)中查找与模式不匹配的行:
-`stdin` (标准输入)中读取数据,不打印匹配模式的行:
`cat {{路径/到/文件}} | grep {{[-v|--invert-match]}} "{{模式字符串}}"`
- 使用扩展 `regex` 式(支持 `?``+``{}``()``|`),不区分大小写模式:
`grep {{[-Ei|--extended-regexp --ignore-case]}} "{{模式字符串}}" {{路径/到/文件}}`
+17 -17
View File
@@ -1,37 +1,37 @@
# grep
> 使用正則表達式在文件中查找字串
> 使用 `regex` 式搜尋檔案中的模式
> 另請參閱:`regex`。
> 更多資訊:<https://www.gnu.org/software/grep/manual/grep.html>。
- 在檔案中尋找字串
- 在檔案中搜尋模式
`grep "{{字串}}" {{檔案/完整/路徑}}`
`grep "{{模式字串}}" {{路徑/至/檔案1 路徑/至/檔案2}}`
-索確切的字串(停用正則表達式)
-尋精確的字串停用 `regex` 式)
`grep {{[-F|--fixed-strings]}} "{{精確字串}}" {{檔案/完整/路徑}}`
`grep {{[-F|--fixed-strings]}} "{{字串}}" {{路徑/至/檔案}}`
- 在目錄中遞迴搜尋模式,顯示相符行的行號並忽略二進位文件
- 在目錄中遞迴搜尋所有檔案中的模式,忽略二進位檔案
`grep {{[-rnI|--recursive --line-number --binary-files=without-match]}} "{{字串}}" {{檔案/完整/路徑}}`
`grep {{[-rI|--recursive --binary-files=without-match]}} "{{模式字串}}" {{路徑/至/目錄}}`
- 使用擴充正則表達式(支援 `?`, `+`, `{}`, `()`, 和 `|`),並啟用不區分大小寫的模式
- 列印每個匹配項周圍、之前或之後的 3 行上下文
`grep {{[-Ei|--extended-regexp --ignore-case]}} "{{字串}}" {{檔案/完整/路徑}}`
`grep {{--context|--before-context|--after-context}} 3 "{{模式字串}}" {{路徑/至/檔案}}`
- 印出每次相符的上下文、之前或之後的 3 行
- 列印每個匹配項的檔案名稱和行號,並帶彩色輸出
`grep {{--context|--before-context|--after-context}} 3 "{{字串}}" {{檔案/完整/路徑}}`
`grep {{[-Hn|--with-filename --line-number]}} --color=always "{{模式字串}}" {{路徑/至/檔案}}`
- 印出包含相符結果的文件名和行號,並啟用彩色輸出
- 僅列印匹配的文本
`grep {{[-Hn|--with-filename --line-number]}} --color=always "{{字串}}" {{檔案/完整/路徑}}`
`grep {{[-o|--only-matching]}} "{{模式字串}}" {{路徑/至/檔案}}`
- 搜尋與模式相符的行,僅印出相符的文字
- `stdin` (標準輸入)中讀取資料,不列印匹配模式的行
`grep {{[-o|--only-matching]}} "{{字串}}" {{檔案/完整/路徑}}`
`cat {{路徑/至/檔案}} | grep {{[-v|--invert-match]}} "{{模式字串}}"`
- 在標準輸入中搜尋不相符模式的行
- 使用擴展 `regex` 式(支援 `?``+``{}``()``|`),不區分大小寫模式
`cat {{檔案/完整/路徑}} | grep {{[-v|--invert-match]}} "{{字串}}"`
`grep {{[-Ei|--extended-regexp --ignore-case]}} "{{模式字串}}" {{路徑/至/檔案}}`