zipgrep

Search inside ZIP archives

TLDR

Search in ZIP
$ zipgrep [pattern] [archive.zip]
Search specific file
$ zipgrep [pattern] [archive.zip] [file.txt]
Case insensitive
$ zipgrep -i [pattern] [archive.zip]
Show line numbers
$ zipgrep -n [pattern] [archive.zip]
Count matches
$ zipgrep -c [pattern] [archive.zip]
List matching files only
$ zipgrep -l [pattern] [archive.zip]
Search but exclude files in subdirectories
$ zipgrep [pattern] [archive.zip] *.[ch] -x */*

SYNOPSIS

zipgrep [egrepoptions] pattern file[.zip] [file(s)] [**-x** xfile(s)_]

DESCRIPTION

zipgrep searches for text patterns inside ZIP archives without requiring manual extraction. It works as a shell wrapper around unzip and egrep, piping decompressed file contents through pattern matching to display results in a familiar grep-like format.Pattern matching supports extended regular expressions through egrep. The output shows the matching filename and line for each hit, similar to running grep on extracted contents. Optional member arguments restrict the search to specific files within the archive.All options before the ZIP archive filename are passed to egrep, so standard grep options like -i for case-insensitive matching, -n for line numbers, -c for match counts, and -l for listing matching filenames are all supported. If the literal filename is not found, the suffix .zip is appended. zipgrep is part of the Info-ZIP suite of utilities.

PARAMETERS

-i

Case insensitive.
-n
Show line numbers.
-c
Count matches.
-l
List files only.
-h
No filename prefix.
-v
Invert match.
pattern
Search pattern.
members
Specific files within the archive to search.
-x xfile(s)
Exclude specified archive members from processing. Wildcards match directory separators.

INSTALL

sudo apt install unzip
sudo dnf install unzip
sudo pacman -S unzip
sudo apk add unzip
sudo zypper install unzip
brew install unzip
nix profile install nixpkgs#unzip

CAVEATS

Shell wrapper around unzip/egrep. May be slow on large archives. Part of Info-ZIP.

HISTORY

zipgrep is part of Info-ZIP utilities. It provides grep functionality for ZIP contents.

SEE ALSO

unzip(1), grep(1), zgrep(1)