LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

ptargrep

Apply pattern matching to the contents of files in a tar archive

TLDR

Search for a pattern and extract matching files
$ ptargrep "[pattern]" [archive.tar.gz]
copy
List matching file paths without extracting
$ ptargrep --list-only "[pattern]" [archive.tar]
copy
Case-insensitive search
$ ptargrep -i "[pattern]" [archive.tar.gz]
copy
Extract matching files using basename only (ignore directory paths)
$ ptargrep --basename "[pattern]" [archive.tar]
copy
Search multiple archives with verbose output
$ ptargrep -v "[pattern]" [archive1.tar.gz] [archive2.tar.bz2]
copy

SYNOPSIS

ptargrep [options] pattern tar-file ...

DESCRIPTION

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.

PARAMETERS

-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.

INSTALL

sudo apt install perl
copy
sudo dnf install perl
copy
sudo pacman -S perl
copy
sudo apk add perl-utils
copy
sudo zypper install perl
copy
brew install perl
copy
nix profile install nixpkgs#perl
copy

CAVEATS

Part of the Perl distribution (Archive::Tar module). Large archives may be slow to process. Memory usage can be high with large files since file contents are read into memory.

HISTORY

ptargrep is distributed with Perl's Archive::Tar module. It provides grep-like functionality for archived content.

SEE ALSO

zgrep(1), tar(1), grep(1), perl(1), zipgrep(1)

Braincup
Open source brain training for math, memory and focus
Braincup mini-games
41 mini-games · Apache-2.0
No ads · No tracking
Play in browser
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid
276 stars
From the maker of Linux Command Library
Copied to clipboard
Braincup
Open source brain training for math, memory and focus. 41 mini-games, from mental arithmetic to Sudoku, N-Back and Solo Chess.
Apache-2.0 licensed · No ads · No tracking · No account
From the maker of Linux Command Library
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid