From 05e31d5f9cd95fdb4a01991118f1a9733ec37a38 Mon Sep 17 00:00:00 2001 From: Aavash Chhetri <68424695+A-atmos@users.noreply.github.com> Date: Sun, 2 Apr 2023 03:28:28 +0545 Subject: [PATCH] xzgrep: add page (#9983) --- pages/common/xzgrep.md | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 pages/common/xzgrep.md diff --git a/pages/common/xzgrep.md b/pages/common/xzgrep.md new file mode 100644 index 0000000000..cb797bb7fa --- /dev/null +++ b/pages/common/xzgrep.md @@ -0,0 +1,33 @@ +# xzgrep + +> Search possibly compressed files with xz, lzma, gzip, bzip2, lzop, or zstd for regular expressions. +> See also: `grep`. +> More information: . + +- Search for a pattern within a file: + +`xzgrep "{{search_pattern}}" {{path/to/compressed/file}}` + +- Search for an exact string (disables regular expressions): + +`xzgrep --fixed-strings "{{exact_string}}" {{path/to/compressed/file}}` + +- Search for a pattern in all files showing line numbers of matches: + +`xzgrep --line-number "{{search_pattern}}" {{path/to/compressed/file}}` + +- Use extended regular expressions (supports `?`, `+`, `{}`, `()` and `|`), in case-insensitive mode: + +`xzgrep --extended-regexp --ignore-case "{{search_pattern}}" {{path/to/file}}` + +- Print 3 lines of context around, before, or after each match: + +`xzgrep --{{context|before-context|after-context}}={{3}} "{{search_pattern}}" {{path/to/file}}` + +- Print file name and line number for each match with color output: + +`xzgrep --with-filename --line-number --color=always "{{search_pattern}}" {{path/to/file}}` + +- Search for lines matching a pattern, printing only the matched text: + +`xzgrep --only-matching "{{search_pattern}}" {{path/to/file}}`