bzfgrep
Search bzip2-compressed files for patterns
TLDR
View documentation for the original command
SYNOPSIS
bzfgrep [fgrep-options] [-e] pattern [file ...]
PARAMETERS
-a, --text
Process binary files as text
-A NUM, --after-context=NUM
Print NUM lines of trailing context after each match
-b, --byte-offset
Print byte offset of each match
-B NUM, --before-context=NUM
Print NUM lines of leading context before each match
-c, --count
Suppress normal output; show only count of matching lines
-C NUM, --context=NUM
Print NUM lines of context around each match
-d ACTION, --devices=ACTION
Handle devices/symbolic links (read|recurse|skip)
-e PATTERN, --regexp=PATTERN
Use PATTERN as fixed string (escape sequences)
-f FILE, --file=FILE
Read fixed patterns from FILE, one per line
-F, --fixed-strings
Equivalent (always fixed-string mode)
-h, --no-filename
Suppress filename prefix on output
-i, --ignore-case
Ignore case distinctions
-l, --files-with-matches
List only filenames with matches
-L, --files-without-matches
List only filenames without matches
-n, --line-number
Prefix matches with line numbers
-q, --quiet, --silent
Suppress all output (exit status only)
-r, --recursive
Recurse into directories
-s, --no-messages
Suppress error messages
-v, --invert-match
Select non-matching lines
-w, --word-regexp
Match only whole words
-x, --line-regexp
Match only whole lines
--color[=WHEN]
Highlight matches (auto|never|always)
--line-buffered
Flush output after each line
DESCRIPTION
bzfgrep is a wrapper utility from the bzip2 package that enables searching for literal (fixed) strings in files compressed with bzip2, without manual decompression. It streams decompression via bzip2 -dc and pipes the output to fgrep (fast grep for fixed strings), treating patterns as exact matches rather than regex. This is efficient for large .bz2 archives, logs, or text dumps.
Key benefits include on-the-fly processing to save disk space/time, support for multiple files (processes each separately), and stdin reading. If a file lacks bzip2 magic bytes, it skips decompression and runs plain fgrep. Patterns can be specified directly or via -e/-f. Output mimics fgrep: matching lines with filename:line:content format for multiple files.
Ideal for sysadmins searching compressed backups or application logs. Performance note: Decompression adds CPU overhead, but streaming avoids full uncompression. Equivalent to bzgrep -F.
CAVEATS
Decompression CPU overhead on large files; streaming but memory-intensive for very big inputs. Only detects bzip2 magic (handles .bz2, stdin); uncompressed files use plain fgrep. Not parallelized; errors on corrupt bz2 files. Deprecated in favor of grep --compress=bz2 in GNU grep 3.34+.
STDIN USAGE
Reads compressed data from stdin if no files given: bzfgrep 'pattern' < file.bz2
MULTI-FILE OUTPUT
Prefix: file.bz2:42:matching line; use -h to omit filename
EQUIVALENT COMMAND
bzfgrep == bzgrep -F; prefer grep -F -z --compress-program=bzip2 on modern systems
HISTORY
Developed by Julian Seward as part of bzip2 (initial release 0.9 1997, 1.0 2000). grep wrappers like bzfgrep added early for convenience; still maintained in bzip2 1.0.8 (2019). Mirrors fgrep behavior for legacy fixed-string efficiency.


