mirror of
https://github.com/tldr-pages/tldr.git
synced 2026-09-01 15:51:29 +08:00
grep, bzgrep, codespell, rg, xzgrep, zgrep: simplify, clarify and reorder examples (#20203)
Co-authored-by: Ivan Baluta <ivanbaluta.dev@gmail.com>
This commit is contained in:
@@ -7,13 +7,13 @@
|
||||
|
||||
`bzgrep "{{search_pattern}}" {{path/to/file}}`
|
||||
|
||||
- Use extended `regex` (supports `?`, `+`, `{}`, `()`, and `|`), in case-insensitive mode:
|
||||
- Recursively search files in a bzip2 compressed `.tar` archive for a pattern:
|
||||
|
||||
`bzgrep {{[-E|--extended-regexp]}} {{[-i|--ignore-case]}} "{{search_pattern}}" {{path/to/file}}`
|
||||
`bzgrep {{[-r|--recursive]}} "{{search_pattern}}" {{path/to/tar_file}}`
|
||||
|
||||
- Print 3 lines of [C]ontext around, [B]efore, or [A]fter each match:
|
||||
|
||||
`bzgrep --{{context|before-context|after-context}} {{3}} "{{search_pattern}}" {{path/to/file}}`
|
||||
`bzgrep {{--context|--before-context|--after-context}} 3 "{{search_pattern}}" {{path/to/file}}`
|
||||
|
||||
- Print file name and line number for each match:
|
||||
|
||||
@@ -23,10 +23,10 @@
|
||||
|
||||
`bzgrep {{[-o|--only-matching]}} "{{search_pattern}}" {{path/to/file}}`
|
||||
|
||||
- Recursively search files in a bzip2 compressed `.tar` archive for a pattern:
|
||||
|
||||
`bzgrep {{[-r|--recursive]}} "{{search_pattern}}" {{path/to/tar_file}}`
|
||||
|
||||
- Search `stdin` for lines that do not match a pattern:
|
||||
|
||||
`cat {{path/to/bz_compressed_file}} | bzgrep {{[-v|--invert-match]}} "{{search_pattern}}"`
|
||||
|
||||
- Use extended `regex` (supports `?`, `+`, `{}`, `()`, and `|`), in case-insensitive mode:
|
||||
|
||||
`bzgrep {{[-E|--extended-regexp]}} {{[-i|--ignore-case]}} "{{search_pattern}}" {{path/to/file}}`
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
- Print 3 lines of [C]ontext around, [B]efore, or [A]fter each match:
|
||||
|
||||
`codespell --{{context|before-context|after-context}} 3`
|
||||
`codespell {{--context|--before-context|--after-context}} 3`
|
||||
|
||||
- Check file names for typos, in addition to file contents:
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
> See also: `regex`.
|
||||
> More information: <https://www.gnu.org/software/grep/manual/grep.html>.
|
||||
|
||||
- Search for a pattern within a file:
|
||||
- Search for a pattern within files:
|
||||
|
||||
`grep "{{search_pattern}}" {{path/to/file1 path/to/file2 ...}}`
|
||||
|
||||
@@ -12,13 +12,9 @@
|
||||
|
||||
`grep {{[-F|--fixed-strings]}} "{{exact_string}}" {{path/to/file}}`
|
||||
|
||||
- Search for a pattern in all files recursively in a directory, showing line numbers of matches, ignoring binary files:
|
||||
- Search for a pattern in all files recursively in a directory, ignoring binary files:
|
||||
|
||||
`grep {{[-rnI|--recursive --line-number --binary-files=without-match]}} "{{search_pattern}}" {{path/to/directory}}`
|
||||
|
||||
- Use extended `regex`es (supports `?`, `+`, `{}`, `()`, and `|`), in case-insensitive mode:
|
||||
|
||||
`grep {{[-Ei|--extended-regexp --ignore-case]}} "{{search_pattern}}" {{path/to/file}}`
|
||||
`grep {{[-rI|--recursive --binary-files=without-match]}} "{{search_pattern}}" {{path/to/directory}}`
|
||||
|
||||
- Print 3 lines of [C]ontext around, [B]efore, or [A]fter each match:
|
||||
|
||||
@@ -28,10 +24,14 @@
|
||||
|
||||
`grep {{[-Hn|--with-filename --line-number]}} --color=always "{{search_pattern}}" {{path/to/file}}`
|
||||
|
||||
- Search for lines matching a pattern, printing only the matched text:
|
||||
- Print only the matched text:
|
||||
|
||||
`grep {{[-o|--only-matching]}} "{{search_pattern}}" {{path/to/file}}`
|
||||
|
||||
- Read data from `stdin` and do not print lines that match a pattern:
|
||||
|
||||
`cat {{path/to/file}} | grep {{[-v|--invert-match]}} "{{search_pattern}}"`
|
||||
|
||||
- Use extended `regex`es (supports `?`, `+`, `{}`, `()`, and `|`), in case-insensitive mode:
|
||||
|
||||
`grep {{[-Ei|--extended-regexp --ignore-case]}} "{{search_pattern}}" {{path/to/file}}`
|
||||
|
||||
+4
-4
@@ -12,6 +12,10 @@
|
||||
|
||||
`rg {{pattern}} {{path/to/file_or_directory}}`
|
||||
|
||||
- Search for a literal string pattern:
|
||||
|
||||
`rg {{[-F|--fixed-strings]}} -- {{string}}`
|
||||
|
||||
- Include hidden files and entries listed in `.gitignore`:
|
||||
|
||||
`rg {{[-.|--hidden]}} --no-ignore {{pattern}}`
|
||||
@@ -31,7 +35,3 @@
|
||||
- Show lines that do not match the pattern:
|
||||
|
||||
`rg {{[-v|--invert-match]}} {{pattern}}`
|
||||
|
||||
- Search for a literal string pattern:
|
||||
|
||||
`rg {{[-F|--fixed-strings]}} -- {{string}}`
|
||||
|
||||
@@ -16,13 +16,9 @@
|
||||
|
||||
`xzgrep {{[-n|--line-number]}} "{{search_pattern}}" {{path/to/file}}`
|
||||
|
||||
- Use extended `regex` (supports `?`, `+`, `{}`, `()`, and `|`), in case-insensitive mode:
|
||||
|
||||
`xzgrep {{[-E|--extended-regexp]}} {{[-i|--ignore-case]}} "{{search_pattern}}" {{path/to/file}}`
|
||||
|
||||
- Print 3 lines of [C]ontext around, [B]efore, or [A]fter each match:
|
||||
|
||||
`xzgrep --{{context|before-context|after-context}} {{3}} "{{search_pattern}}" {{path/to/file}}`
|
||||
`xzgrep {{--context|--before-context|--after-context}} 3 "{{search_pattern}}" {{path/to/file}}`
|
||||
|
||||
- Print file name and line number for each match with color output:
|
||||
|
||||
@@ -31,3 +27,7 @@
|
||||
- Search for lines matching a pattern, printing only the matched text:
|
||||
|
||||
`xzgrep {{[-o|--only-matching]}} "{{search_pattern}}" {{path/to/file}}`
|
||||
|
||||
- Use extended `regex` (supports `?`, `+`, `{}`, `()`, and `|`), in case-insensitive mode:
|
||||
|
||||
`xzgrep {{[-E|--extended-regexp]}} {{[-i|--ignore-case]}} "{{search_pattern}}" {{path/to/file}}`
|
||||
|
||||
@@ -7,6 +7,10 @@
|
||||
|
||||
`zgrep {{pattern}} {{path/to/compressed_file}}`
|
||||
|
||||
- Print 3 lines of [C]ontext around, [B]efore, or [A]fter each match:
|
||||
|
||||
`zgrep {{--context|--before-context|--after-context}} 3 {{pattern}} {{path/to/compressed_file}}`
|
||||
|
||||
- Grep a pattern in a compressed file (case-insensitive):
|
||||
|
||||
`zgrep {{[-i|--ignore-case]}} {{pattern}} {{path/to/compressed_file}}`
|
||||
@@ -23,10 +27,6 @@
|
||||
|
||||
`zgrep {{[-e|--regexp]}} "{{pattern_1}}" {{[-e|--regexp]}} "{{pattern_2}}" {{path/to/compressed_file}}`
|
||||
|
||||
- Use extended `regex` (supporting `?`, `+`, `{}`, `()`, and `|`):
|
||||
- Use extended `regex` (supports `?`, `+`, `{}`, `()`, and `|`):
|
||||
|
||||
`zgrep {{[-E|--extended-regexp]}} {{regex}} {{path/to/file}}`
|
||||
|
||||
- Print 3 lines of [C]ontext around, [B]efore, or [A]fter each match:
|
||||
|
||||
`zgrep --{{context|before-context|after-context}} 3 {{pattern}} {{path/to/compressed_file}}`
|
||||
|
||||
Reference in New Issue
Block a user