1
0
Fork 0
mirror of https://github.com/tldr-pages/tldr.git synced 2025-07-07 19:15:24 +02:00
tldr/pages/common/xzgrep.md

34 lines
1.2 KiB
Markdown
Raw Normal View History

2023-04-02 03:28:28 +05:45
# xzgrep
> Search files possibly compressed with `xz`, `lzma`, `gzip`, `bzip2`, `lzop`, or `zstd` using regular expressions.
2023-04-02 03:28:28 +05:45
> See also: `grep`.
> More information: <https://manned.org/xzgrep>.
2023-04-02 03:28:28 +05:45
- Search for a pattern within a file:
`xzgrep "{{search_pattern}}" {{path/to/file}}`
2023-04-02 03:28:28 +05:45
- Search for an exact string (disables regular expressions):
`xzgrep {{[-F|--fixed-strings]}} "{{exact_string}}" {{path/to/file}}`
2023-04-02 03:28:28 +05:45
- Search for a pattern in all files showing line numbers of matches:
`xzgrep {{[-n|--line-number]}} "{{search_pattern}}" {{path/to/file}}`
2023-04-02 03:28:28 +05:45
- Use extended regular expressions (supports `?`, `+`, `{}`, `()` and `|`), in case-insensitive mode:
`xzgrep {{[-E|--extended-regexp]}} {{[-i|--ignore-case]}} "{{search_pattern}}" {{path/to/file}}`
2023-04-02 03:28:28 +05:45
- Print 3 lines of [C]ontext around, [B]efore, or [A]fter each match:
2023-04-02 03:28:28 +05:45
`xzgrep --{{context|before-context|after-context}} {{3}} "{{search_pattern}}" {{path/to/file}}`
2023-04-02 03:28:28 +05:45
- Print file name and line number for each match with color output:
`xzgrep {{[-H|--with-filename]}} {{[-n|--line-number]}} --color=always "{{search_pattern}}" {{path/to/file}}`
2023-04-02 03:28:28 +05:45
- Search for lines matching a pattern, printing only the matched text:
`xzgrep {{[-o|--only-matching]}} "{{search_pattern}}" {{path/to/file}}`