LinuxCommandLibrary

bzfgrep

Search bzip2 files for fixed string patterns

TLDR

Search for a fixed string in a bzip2 compressed file
$ bzfgrep "[string]" [path/to/file.bz2]
copy
Search case-insensitively
$ bzfgrep -i "[string]" [path/to/file.bz2]
copy
Print line numbers with matches
$ bzfgrep -n "[string]" [path/to/file.bz2]
copy
Search multiple compressed files
$ bzfgrep "[string]" [file1.bz2] [file2.bz2]
copy
Count matching lines
$ bzfgrep -c "[string]" [path/to/file.bz2]
copy

SYNOPSIS

bzfgrep [fgrepoptions] [**-e**] pattern [filename..._]

DESCRIPTION

bzfgrep searches possibly bzip2-compressed files for lines matching a fixed string pattern. It transparently decompresses .bz2 files before searching and passes all options directly to fgrep.
Unlike bzgrep or bzegrep, bzfgrep interprets the pattern as a literal string rather than a regular expression. This makes it faster for simple string searches and avoids the need to escape special characters.
If no file is specified, bzfgrep reads from standard input, decompressing if necessary.

PARAMETERS

All fgrep options are supported, including:
-i

Case-insensitive matching
-n
Print line numbers
-c
Print only a count of matching lines
-v
Invert match (show non-matching lines)
-l
Print only filenames containing matches
-e pattern
Specify the pattern (useful if pattern starts with -)

CAVEATS

The GREP environment variable can be set to specify an alternate grep program. The pattern is treated as a fixed string, not a regular expression. For regex searches, use bzgrep or bzegrep.

SEE ALSO

bzgrep(1), bzegrep(1), fgrep(1), bzip2(1)

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard