← 返回命令列表

Linux command

xzegrep 命令

文件

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

常用示例

Search

xzegrep "[pattern]" [file.xz]

Case-insensitive

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

Search recursively

xzegrep -r "[pattern]" [directory]

Show only matching files

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

Show line numbers

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

Print N lines of context

xzegrep -C [3] "[pattern]" [file.xz]

说明

xzegrep invokes grep -E on the decompressed contents of files compressed with xz, lzma, gzip, or bzip2 (detected by extension). It is the xz-utils wrapper equivalent to zegrep for gzip files: a convenience shortcut for xzgrep -E, taking an extended regular expression and forwarding all other arguments to grep. If no file is given, xzegrep reads from standard input. Most options accepted by grep can be passed through.

参数

-i, --ignore-case
Ignore case distinctions.
-l, --files-with-matches
Print only the names of files containing matches.
-n, --line-number
Prefix each line with its line number.
-c, --count
Print only the count of matching lines per file.
-v, --invert-match
Select non-matching lines.
-h, --no-filename
Suppress filename prefix in output.
-H, --with-filename
Always print filename prefix.
-r, --recursive
Recursively search directories.
-A _N_ / -B _N_ / -C _N_
Print N lines after / before / around each match.
-q, --quiet
Suppress all normal output; exit 0 if any line matches.

FAQ

What is the xzegrep command used for?

xzegrep invokes grep -E on the decompressed contents of files compressed with xz, lzma, gzip, or bzip2 (detected by extension). It is the xz-utils wrapper equivalent to zegrep for gzip files: a convenience shortcut for xzgrep -E, taking an extended regular expression and forwarding all other arguments to grep. If no file is given, xzegrep reads from standard input. Most options accepted by grep can be passed through.

How do I run a basic xzegrep example?

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

What does -i, --ignore-case do in xzegrep?

Ignore case distinctions.