← 返回命令列表

Linux command

xzgrep 命令

文件

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

常用示例

Search for a pattern in an xz-compressed file

xzgrep "[pattern]" [file.xz]

Search case-insensitively

xzgrep -i "[pattern]" [file.xz]

Count matching lines

xzgrep -c "[pattern]" [file.xz]

Show line numbers with matches

xzgrep -n "[pattern]" [file.xz]

List files containing a match

xzgrep -l "[pattern]" [*.xz]

Search using extended regular expressions

xzgrep -E "[regex_pattern]" [file.xz]

说明

xzgrep searches xz, lzma, and lzip compressed files for lines matching a pattern. It decompresses the data on the fly and passes it to grep, without creating temporary files on disk. All standard grep options are supported. Also available as xzegrep and xzfgrep variants.

参数

-i
Case insensitive search.
-n
Show line numbers.
-c
Count matching lines.
-l
List only filenames containing matches.
-v
Invert match (show non-matching lines).
-E
Use extended regular expressions (like egrep).
-F
Use fixed strings instead of regular expressions (like fgrep).
-h
Suppress filename prefix on output.
-H
Always print filename prefix.

FAQ

What is the xzgrep command used for?

xzgrep searches xz, lzma, and lzip compressed files for lines matching a pattern. It decompresses the data on the fly and passes it to grep, without creating temporary files on disk. All standard grep options are supported. Also available as xzegrep and xzfgrep variants.

How do I run a basic xzgrep example?

Run `xzgrep "[pattern]" [file.xz]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -i do in xzgrep?

Case insensitive search.