xzgrep - Man Page
search possibly-compressed files for patterns
Examples (TL;DR)
- Search for a pattern within a file:
xzgrep "search_pattern" path/to/file
- Search for an exact string (disables regular expressions):
xzgrep --fixed-strings "exact_string" path/to/file
- Search for a pattern in all files showing line numbers of matches:
xzgrep --line-number "search_pattern" path/to/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
Synopsis
xzgrep [option...] [pattern_list] [file...]
xzegrep ...
xzfgrep ...
lzgrep ...
lzegrep ...
lzfgrep ...
Description
xzgrep invokes grep(1) on uncompressed contents of files. The formats of the files are determined from the filename suffixes. Any file with a suffix supported by xz(1), gzip(1), bzip2(1), lzop(1), zstd(1), or lz4(1) will be decompressed; all other files are assumed to be uncompressed.
If no files are specified or file is - then standard input is read. When reading from standard input, only files supported by xz(1) are decompressed. Other files are assumed to be in uncompressed form already.
Most options of grep(1) are supported. However, the following options are not supported:
-r, --recursive
-R, --dereference-recursive
-d, --directories=action
-Z, --null
-z, --null-data
--include=glob
--exclude=glob
--exclude-from=file
--exclude-dir=glob
xzegrep is an alias for xzgrep -E. xzfgrep is an alias for xzgrep -F.
The commands lzgrep, lzegrep, and lzfgrep are provided for backward compatibility with LZMA Utils.
Exit Status
- 0
At least one match was found from at least one of the input files. No errors occurred.
- 1
No matches were found from any of the input files. No errors occurred.
- >1
One or more errors occurred. It is unknown if matches were found.
Environment
- GREP
If GREP is set to a non-empty value, it is used instead of grep, grep -E, or grep -F.
See Also
grep(1), xz(1), gzip(1), bzip2(1), lzop(1), zstd(1), lz4(1), zgrep(1)
Referenced By
The man pages lzegrep(1), lzfgrep(1), lzgrep(1), xzegrep(1) and xzfgrep(1) are aliases of xzgrep(1).