← 返回命令列表

Linux command

ptargrep 命令

文件

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

常用示例

Search for a pattern and extract matching files

ptargrep "[pattern]" [archive.tar.gz]

List matching file paths without extracting

ptargrep --list-only "[pattern]" [archive.tar]

Case-insensitive search

ptargrep -i "[pattern]" [archive.tar.gz]

Extract matching files using basename only (ignore directory paths)

ptargrep --basename "[pattern]" [archive.tar]

Search multiple archives with verbose output

ptargrep -v "[pattern]" [archive1.tar.gz] [archive2.tar.bz2]

说明

ptargrep allows you to apply pattern matching to the contents of files in a tar archive. The pattern is used as a Perl regular expression. The default behavior is to extract each matching file from the archive. Use --list-only to only print pathnames of matching files instead. Compressed archives (gzip, bzip2, xz) are handled automatically based on the file extension. Multiple tar archive filenames can be specified and they will each be processed in turn.

参数

-b, --basename
When extracting matching files, ignore the directory path from the archive and write to the current directory using only the basename. Files with identical names will overwrite each other.
-i, --ignore-case
Case-insensitive pattern matching.
-l, --list-only
Print the pathname of each matching file to stdout instead of extracting.
-v, --verbose
Log debugging info to stderr.
-?, --help
Display help documentation.

FAQ

What is the ptargrep command used for?

ptargrep allows you to apply pattern matching to the contents of files in a tar archive. The pattern is used as a Perl regular expression. The default behavior is to extract each matching file from the archive. Use --list-only to only print pathnames of matching files instead. Compressed archives (gzip, bzip2, xz) are handled automatically based on the file extension. Multiple tar archive filenames can be specified and they will each be processed in turn.

How do I run a basic ptargrep example?

Run `ptargrep "[pattern]" [archive.tar.gz]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -b, --basename do in ptargrep?

When extracting matching files, ignore the directory path from the archive and write to the current directory using only the basename. Files with identical names will overwrite each other.