zgrep - search compressed files for a regular expression
zgrep [options] <pattern>
[files]
zgrep is a front end to the program grep that allows transparent
search on any combination of compressed and uncompressed files. If any file
given is compressed, its decompressed content is used. If a file given does
not exist, and its name does not end with one of the known extensions, zgrep
tries the compressed file names corresponding to the formats supported. If a
file fails to decompress, zgrep continues searching the rest of the
files.
If a file is specified as '-', data are read from standard input,
decompressed if needed, and fed to grep. Data read from standard input must
be of the same type; all uncompressed or all in the same compressed
format.
If no files are specified, recursive searches examine the current
working directory, and nonrecursive searches read standard input.
'zgrep --verbose -V' prints the version of the grep
program used.
The formats supported are bzip2, gzip, lzip, xz, and zstd.
Exit status is 0 if match, 1 if no match, 2 if trouble. Some
options only work if the grep program used supports them.
- --help
- display this help and exit
- -V, --version
- output version information and exit
- -a, --text
- treat all files as text
- -A,
--after-context=<n>
- print <n> lines of trailing context
- -b,
--byte-offset
- print the byte offset of each line
- -B,
--before-context=<n>
- print <n> lines of leading context
- -c, --count
- only print a count of matching lines per file
- -C,
--context=<n>
- print <n> lines of output context
- --color[=<when>]
- show matched strings in color
- -e,
--regexp=<pattern>
- use <pattern> as the pattern to match
- -E,
--extended-regexp
- <pattern> is an extended regular expression
- -f,
--file=<file>
- obtain patterns from <file>
- -F,
--fixed-strings
- <pattern> is a set of newline-separated strings
- -G,
--basic-regexp
- <pattern> is a basic regular expression (default)
- -h,
--no-filename
- suppress the prefixing file name on output
- -H,
--with-filename
- print the file name for each match
- -i,
--ignore-case
- ignore case distinctions
- -I
- ignore binary files
- -l,
--files-with-matches
- only print names of files containing matches
- -L,
--files-without-match
- only print names of files containing no matches
- --label=<label>
- use <label> as file name for standard input
- --line-buffered
- flush output on every line
- -m,
--max-count=<n>
- stop after <n> matches
- -M,
--format=<list>
- process only the formats in <list>
- -n,
--line-number
- print the line number of each line
- -N,
--no-rcfile
- don't read runtime configuration file
- -o,
--only-matching
- show only the part of a line matching <pattern>
- -O,
--force-format=<fmt>
- force the input format
- -P,
--perl-regexp
- <pattern> is a Perl regular expression
- -q, --quiet,
--silent
- suppress all messages
- -r,
--recursive
- operate recursively on directories
- -R,
--dereference-recursive
- recursively follow symbolic links
- -s,
--no-messages
- suppress error messages
- -T,
--initial-tab
- make tabs line up (if needed)
- -U, --binary
- don't strip CR characters at EOL (DOS/Windows)
- -v,
--invert-match
- select non-matching lines
- --verbose
- verbose mode (show error messages)
- -w,
--word-regexp
- match only whole words
- -x,
--line-regexp
- match only whole lines
- -Z, --null
- print 0 byte (ASCII NUL) after file name
- --bz2=<command>
- set compressor and options for bzip2 format
- --gz=<command>
- set compressor and options for gzip format
- --lz=<command>
- set compressor and options for lzip format
- --xz=<command>
- set compressor and options for xz format
- --zst=<command>
- set compressor and options for zstd format
Valid formats for options '-M' and '-O' are 'bz2', 'gz', 'lz',
'xz', 'zst', and 'un' for uncompressed.
Numbers may be followed by a multiplier: k = kB = 10^3 = 1000, Ki
= KiB = 2^10 = 1024, M = 10^6, Mi = 2^20, G = 10^9, Gi = 2^30, etc...
Report bugs to zutils-bug@nongnu.org
Zutils home page: http://www.nongnu.org/zutils/zutils.html
Copyright © 2023 Antonio Diaz Diaz. License GPLv2+: GNU GPL
version 2 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it. There is NO
WARRANTY, to the extent permitted by law.
The full documentation for zgrep is maintained as a Texinfo
manual. If the info and zgrep programs are properly installed
at your site, the command
- info zutils
should give you access to the complete manual.