← 返回命令列表

Linux command

bzegrep 命令

文件

复制后可按需替换文件名、目录或参数。

常用示例

Search for an extended regex pattern in a bzip2 compressed file

bzegrep "[pattern]" [path/to/file.bz2]

Search case-insensitively

bzegrep -i "[pattern]" [path/to/file.bz2]

Print line numbers with matches

bzegrep -n "[pattern]" [path/to/file.bz2]

Search multiple compressed files

bzegrep "[pattern]" [file1.bz2] [file2.bz2]

Count matching lines

bzegrep -c "[pattern]" [path/to/file.bz2]

Search from stdin

bzcat [path/to/file.bz2] | bzegrep "[pattern]"

说明

bzegrep searches possibly bzip2-compressed files for lines matching an extended regular expression pattern. It transparently decompresses .bz2 files before searching and passes all options directly to egrep. If no file is specified, bzegrep reads from standard input, decompressing if necessary. This allows it to be used in pipelines with other bzip2 utilities. The command is equivalent to running bzgrep but using egrep (extended grep) for pattern matching, supporting extended regular expression syntax including +, ?, |, and parentheses for grouping.

参数

-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 names of files containing matches
-h
Suppress the filename prefix on output (when searching multiple files)
-e _pattern_
Specify the pattern (useful if pattern starts with -)

FAQ

What is the bzegrep command used for?

bzegrep searches possibly bzip2-compressed files for lines matching an extended regular expression pattern. It transparently decompresses .bz2 files before searching and passes all options directly to egrep. If no file is specified, bzegrep reads from standard input, decompressing if necessary. This allows it to be used in pipelines with other bzip2 utilities. The command is equivalent to running bzgrep but using egrep (extended grep) for pattern matching, supporting extended regular expression syntax including +, ?, |, and parentheses for grouping.

How do I run a basic bzegrep example?

Run `bzegrep "[pattern]" [path/to/file.bz2]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -i do in bzegrep?

Case-insensitive matching