# phpman > man > XZGREP(1)

> **TLDR:** Search files possibly compressed with `xz`, `lzma`, `gzip`, `bzip2`, `lzop`, or `zstd` using `regex`.
>
- Search for a pattern within a file:
  `xzgrep "{{search_pattern}}" {{path/to/file}}`
- Search for an exact string (disables `regex`):
  `xzgrep {{-F|--fixed-strings}} "{{exact_string}}" {{path/to/file}}`
- Search for a pattern in all files showing line numbers of matches:
  `xzgrep {{-n|--line-number}} "{{search_pattern}}" {{path/to/file}}`
- Print 3 lines of [C]ontext around, [B]efore, or [A]fter 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 {{-H|--with-filename}} {{-n|--line-number}} --color=always "{{search_pattern}}" {{path/to/file}}`
- Search for lines matching a pattern, printing only the matched text:
  `xzgrep {{-o|--only-matching}} "{{search_pattern}}" {{path/to/file}}`
- Use extended `regex` (supports `?`, `+`, `{}`, `()`, and `|`), in case-insensitive mode:
  `xzgrep {{-E|--extended-regexp}} {{-i|--ignore-case}} "{{search_pattern}}" {{path/to/file}}`

*Source: tldr-pages*

---

[XZGREP(1)](https://www.chedong.com/phpMan.php/man/XZGREP/1/markdown)                                     XZ Utils                                     [XZGREP(1)](https://www.chedong.com/phpMan.php/man/XZGREP/1/markdown)



## NAME
       xzgrep - search compressed files for a regular expression

## SYNOPSIS
       **xzgrep** [_grep_options_] [**-e**] _pattern_ _file_...
       **xzegrep** ...
       **xzfgrep** ...
       **lzgrep** ...
       **lzegrep** ...
       **lzfgrep** ...

## DESCRIPTION
       **xzgrep**  invokes  [**grep**(1)](https://www.chedong.com/phpMan.php/man/grep/1/markdown)  on _files_ which may be either uncompressed or compressed with [**xz**(1)](https://www.chedong.com/phpMan.php/man/xz/1/markdown),
       [**lzma**(1)](https://www.chedong.com/phpMan.php/man/lzma/1/markdown), [**gzip**(1)](https://www.chedong.com/phpMan.php/man/gzip/1/markdown), [**bzip2**(1)](https://www.chedong.com/phpMan.php/man/bzip2/1/markdown), [**lzop**(1)](https://www.chedong.com/phpMan.php/man/lzop/1/markdown), or [**zstd**(1)](https://www.chedong.com/phpMan.php/man/zstd/1/markdown).  All options specified are  passed  directly
       to [**grep**(1)](https://www.chedong.com/phpMan.php/man/grep/1/markdown).

       If no _file_ is specified, then standard input is decompressed if necessary and fed to [**grep**(1)](https://www.chedong.com/phpMan.php/man/grep/1/markdown).
       When reading from standard input, [**gzip**(1)](https://www.chedong.com/phpMan.php/man/gzip/1/markdown), [**bzip2**(1)](https://www.chedong.com/phpMan.php/man/bzip2/1/markdown), [**lzop**(1)](https://www.chedong.com/phpMan.php/man/lzop/1/markdown), and  [**zstd**(1)](https://www.chedong.com/phpMan.php/man/zstd/1/markdown)  compressed  files
       are not supported.

       If  **xzgrep**  is  invoked  as  **xzegrep**  or **xzfgrep** then [**egrep**(1)](https://www.chedong.com/phpMan.php/man/egrep/1/markdown) or [**fgrep**(1)](https://www.chedong.com/phpMan.php/man/fgrep/1/markdown) is used instead of
       [**grep**(1)](https://www.chedong.com/phpMan.php/man/grep/1/markdown).  The same applies to names **lzgrep**, **lzegrep**, and  **lzfgrep**,  which  are  provided  for
       backward compatibility with LZMA Utils.

## ENVIRONMENT
       **GREP**   If  the **GREP** environment variable is set, **xzgrep** uses it instead of [**grep**(1)](https://www.chedong.com/phpMan.php/man/grep/1/markdown), [**egrep**(1)](https://www.chedong.com/phpMan.php/man/egrep/1/markdown),
              or [**fgrep**(1)](https://www.chedong.com/phpMan.php/man/fgrep/1/markdown).

## SEE ALSO
       [**grep**(1)](https://www.chedong.com/phpMan.php/man/grep/1/markdown), [**xz**(1)](https://www.chedong.com/phpMan.php/man/xz/1/markdown), [**gzip**(1)](https://www.chedong.com/phpMan.php/man/gzip/1/markdown), [**bzip2**(1)](https://www.chedong.com/phpMan.php/man/bzip2/1/markdown), [**lzop**(1)](https://www.chedong.com/phpMan.php/man/lzop/1/markdown), [**zstd**(1)](https://www.chedong.com/phpMan.php/man/zstd/1/markdown), [**zgrep**(1)](https://www.chedong.com/phpMan.php/man/zgrep/1/markdown)



Tukaani                                      2020-12-05                                    [XZGREP(1)](https://www.chedong.com/phpMan.php/man/XZGREP/1/markdown)
