From fb52b80b2f86e1e50834bae9fd5b4a9e4fba8bb5 Mon Sep 17 00:00:00 2001 From: ivuorinen Date: Fri, 7 Jun 2024 00:14:40 +0000 Subject: [PATCH] Update cheatsheets --- tldr/grep | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tldr/grep b/tldr/grep index e6274b63..4f38a847 100644 --- a/tldr/grep +++ b/tldr/grep @@ -14,15 +14,15 @@ source: https://github.com/tldr-pages/tldr.git - Search for an exact string (disables regular expressions): -`grep --fixed-strings "{{exact_string}}" {{path/to/file}}` +`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: -`grep --recursive --line-number --binary-files {{without-match}} "{{search_pattern}}" {{path/to/directory}}` +`grep {{-r|--recursive}} {{-n|--line-number}} --binary-files {{without-match}} "{{search_pattern}}" {{path/to/directory}}` - Use extended regular expressions (supports `?`, `+`, `{}`, `()` and `|`), in case-insensitive mode: -`grep --extended-regexp --ignore-case "{{search_pattern}}" {{path/to/file}}` +`grep {{-E|--extended-regexp}} {{-i|--ignore-case}} "{{search_pattern}}" {{path/to/file}}` - Print 3 lines of context around, before, or after each match: @@ -30,12 +30,12 @@ source: https://github.com/tldr-pages/tldr.git - Print file name and line number for each match with color output: -`grep --with-filename --line-number --color=always "{{search_pattern}}" {{path/to/file}}` +`grep {{-H|--with-filename}} {{-n|--line-number}} --color=always "{{search_pattern}}" {{path/to/file}}` - Search for lines matching a pattern, printing only the matched text: -`grep --only-matching "{{search_pattern}}" {{path/to/file}}` +`grep {{-o|--only-matching}} "{{search_pattern}}" {{path/to/file}}` - Search `stdin` for lines that do not match a pattern: -`cat {{path/to/file}} | grep --invert-match "{{search_pattern}}"` +`cat {{path/to/file}} | grep {{-v|--invert-match}} "{{search_pattern}}"`