ZGREP(1)

✨ NAME ✨

zgrep β€” bestie, it searches compressed files for a regular expression πŸ’–


πŸŽ€ SYNOPSIS πŸŽ€

zgrep [options] <pattern> [files]

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so zgrep is literally a front end to the program grep that lets you do a transparent search on any combination of compressed and uncompressed files. no cap. if any file you hand it is compressed, its decompressed content is what gets used. πŸ’…

if a file you gave doesn't exist, and its name doesn't end with one of the known extensions, zgrep will try the compressed file names corresponding to the formats supported until one is found. and if a file fails to decompress? it does NOT spiral, it just continues searching the rest of the files. queen behavior. πŸ‘‘

if a file is specified as -, data are read from standard input, decompressed if needed, and fed to grep. ⚠️ important: data read from standard input must be of the same type; all uncompressed or all in the same compressed format. mixing? not the vibe.

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. iconic lineup fr fr.

heads up bestie: some options only work if the grep program used supports them. 😭 not everything is guaranteed.

🌸 OPTIONS 🌸

  • -?, --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
  • --exclude=<pattern> β€” exclude files matching a shell pattern
  • -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. ✨ that's the whole list, memorize it bestie.


πŸ’€ EXIT STATUS πŸ’€

  • 0 if at least one match was found πŸŽ‰
  • 1 if no matches were found 😭
  • 2 if trouble πŸ’€

πŸ› REPORTING BUGS πŸ›

found a bug? not the vibe, but please tell them: Report bugs to zutils-bug@nongnu.org Zutils home page: http://www.nongnu.org/zutils/zutils.html


Copyright Β© 2026 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.


🌈 SEE ALSO 🌈

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. iykyk 🧚


k that's the whole page bestie β€” this is zutils version 1.16, dated February 2026. go forth and grep the compressed files, you absolute icon. πŸ’œπŸ¦‹βœ¨

πŸ“¦ where this page comes from