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

33 lines
1.1 KiB
Markdown
Raw Normal View History

2021-10-24 16:08:51 -05:00
# bzgrep
> Find patterns in `bzip2` compressed files using `grep`.
2021-10-24 16:08:51 -05:00
> More information: <https://manned.org/bzgrep>.
- Search for a pattern within a compressed file:
`bzgrep "{{search_pattern}}" {{path/to/file}}`
- Use extended regular expressions (supports `?`, `+`, `{}`, `()` and `|`), in case-insensitive mode:
`bzgrep {{[-E|--extended-regexp]}} {{[-i|--ignore-case]}} "{{search_pattern}}" {{path/to/file}}`
2021-10-24 16:08:51 -05:00
- Print 3 lines of [C]ontext around, [B]efore, or [A]fter each match:
2021-10-24 16:08:51 -05:00
`bzgrep --{{context|before-context|after-context}} {{3}} "{{search_pattern}}" {{path/to/file}}`
2021-10-24 16:08:51 -05:00
- Print file name and line number for each match:
`bzgrep {{[-H|--with-filename]}} {{[-n|--line-number]}} "{{search_pattern}}" {{path/to/file}}`
2021-10-24 16:08:51 -05:00
- Search for lines matching a pattern, printing only the matched text:
`bzgrep {{[-o|--only-matching]}} "{{search_pattern}}" {{path/to/file}}`
2021-10-24 16:08:51 -05:00
- Recursively search files in a bzip2 compressed tar archive for a pattern:
2021-10-24 16:08:51 -05:00
`bzgrep {{[-r|--recursive]}} "{{search_pattern}}" {{path/to/tar/file}}`
2021-10-24 16:08:51 -05:00
- Search `stdin` for lines that do not match a pattern:
2021-10-24 16:08:51 -05:00
`cat {{/path/to/bz/compressed/file}} | bzgrep {{[-v|--invert-match]}} "{{search_pattern}}"`