Forrest logo
back to the zipgrep tool

zipgrep:tldr:bee6b

zipgrep: Print file name and line number for each match.
$ zipgrep -H -n "${search_pattern}" ${filename-zip}
try on your machine

The command zipgrep -H -n "${search_pattern}" ${filename.zip} is used to search for a specific pattern or a regular expression inside files within a zip archive.

Here is a breakdown of each component:

  • zipgrep: It is a command-line utility that allows you to search within zip archives.
  • -H: This option asks zipgrep to print the filename followed by a colon for each matched line. Without this option, it would only display the matched lines.
  • -n: This option asks zipgrep to also print the line numbers of the matched lines.
  • "${search_pattern}": This is the pattern or regular expression that you want to search within the zip archive. You would replace ${search_pattern} with the actual pattern you are looking for.
  • ${filename-zip}: This is the name of the zip archive file that you want to search within. You would replace ${filename-zip} with the actual filename and its extension.

By running this command, zipgrep will search for the specified pattern within the files present inside the zip archive, and display the filename, line numbers, and the matched lines (if found).

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the zipgrep tool