mirror of
https://github.com/ivuorinen/cheatsheet-tldr.git
synced 2026-03-05 08:55:47 +00:00
Update cheatsheets
This commit is contained in:
16
tldr/grep
16
tldr/grep
@@ -9,7 +9,7 @@ source: https://github.com/tldr-pages/tldr.git
|
||||
> 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 ...}}`
|
||||
|
||||
@@ -17,13 +17,9 @@ source: https://github.com/tldr-pages/tldr.git
|
||||
|
||||
`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:
|
||||
|
||||
@@ -33,10 +29,14 @@ source: https://github.com/tldr-pages/tldr.git
|
||||
|
||||
`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}}`
|
||||
|
||||
Reference in New Issue
Block a user