ZGREP(1)

๐Ÿ“ฆ
version 1.15 ยท 2 versions
, in alpine 3.24

๐Ÿ’… ZGREP(1) โ€” the zgrep manual page, but make it make sense

okay so this is the <pink>User Commands</pink> manual for zgrep, bestie. it's giving "grep but it can also open the compressed stuff" and honestly? iconic. let's go ๐Ÿซถ


โœจ NAME โœจ

zgrep โ€” search compressed files for a regular expression ๐Ÿ”


๐ŸŽ€ SYNOPSIS ๐ŸŽ€

zgrep [options] <pattern> [files]

that's literally it. that's the whole vibe. [options] go brrr, then your <pattern>, then the [files] you wanna dig through โœจ


๐ŸŒธ DESCRIPTION ๐ŸŒธ

so zgrep is a front end to the program grep that lets you do a transparent search on any combination of compressed and uncompressed files. yes, any combination, she's flexible like that ๐Ÿ’…

if any file you give her is compressed, its decompressed content is what gets used. and if a file doesn't exist and its name doesn't end with one of the known extensions, zgrep tries the compressed file names corresponding to the formats supported until one is found. she's out here doing detective work fr fr ๐Ÿ•ต๏ธโ€โ™€๏ธ

and if a file fails to decompress? no big deal, she does not spiral. zgrep just continues searching the rest of the files. resilient queen ๐Ÿ‘‘

if a file is specified as -, data are read from standard input, decompressed if needed, and fed to grep. but heads up bestie โ€” data read from standard input must be of the same type; all uncompressed or all in the same compressed format. no mixing, that's the rule ๐Ÿ™ˆ

if no files are specified, recursive searches examine the current working directory, and nonrecursive searches read standard input. iykyk ๐Ÿ“

'zgrep --verbose -V' prints the version of the grep program used. cute, right? ๐ŸŽ€

the formats supported are bzip2, gzip, lzip, xz, and zstd. the whole squad ๐ŸŒˆ

exit status is 0 if match, 1 if no match, 2 if trouble. very demure, very mindful ๐Ÿ’–

lowkey important: some options only work if the grep program used supports them. not everything is guaranteed, so don't come for her if a flag ghosts you ๐Ÿ˜ญ

๐Ÿ’… OPTIONS ๐Ÿ’…

okay this is the big one. buckle up, we're going through all of them, no skipping, periodt ๐ŸŒŸ

  • --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 ๐ŸŒˆ (yes the <when> is optional, she's chill)
  • -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, so Hello and hELLo are the same bestie ๐Ÿ’–
  • -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, the contrarian icon ๐Ÿ™ƒ
  • --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. write that down bestie ๐Ÿ“

numbers may be followed by a multiplier, and this is genuinely so useful: k = kB = 10^3 = 1000, Ki = KiB = 2^10 = 1024, M = 10^6, Mi = 2^20, G = 10^9, Gi = 2^30, etc... math girlies rise ๐Ÿงฎโœจ


๐Ÿฆ‹ REPORTING BUGS ๐Ÿฆ‹

found a bug? don't suffer in silence, tell the devs ๐Ÿซถ


Copyright ยฉ 2025 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. so like, she's free but she's not gonna fix your life, no cap ๐Ÿ’€


๐ŸŒŸ 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. go read it, it's giving lore drop ๐Ÿ“–โœจ


and that's the whole page, bestie ๐ŸŽ€ this was zutils version 1.15, dated May 2025, and it's filed under ZGREP(1) โ€” mwah, love u, go grep something ๐Ÿ’œ๐Ÿฆ‹

๐Ÿ“ฆ where this page comes from