brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: zipgrep searches the text inside a zip without unpacking it

Search
~/tips/tip-zipgrep-inside-archive

zipgrep db_host backup.zip

Find which file in an archive mentions a word, without extracting anything.

Somewhere in an old zip is the config line I need, and unpacking hundreds of files to find it makes a mess. This one command looks inside for me.

zipgrep db_host backup.zip

Each match is printed with the name of the member it came from:

app.conf:db_host=example.com
readme.txt:db_host mentioned

Options before the archive name work like with grep, so -i ignores case and -n adds line numbers. After the archive name you can name which members to search, with wildcards in quotes:

zipgrep -i db_host backup.zip '*.conf'

To leave some out, add -x followed by a pattern.

It is a small script around unzip and egrep, so both need to be installed, and the pattern is an extended regular expression: put a backslash before a literal dot or bracket. On a large archive it is not fast, since each member is unpacked in turn. It only understands zip files, so for a .tar.gz you need another approach. Office documents are zips too, but their text is wrapped in XML, so matches there look messy.

Further reading: zipgrep(1) man page

Going deeper: Run degoog on Unraid as your own search page, compared with SearXNG and 4get

More Search tips !!wfr Wau Holland pdfgrep -rin "warranty" ~/Documents "fatal error" repo:github-linguist/linguist is:open involves:@me The <search> element replaces role="search" on a form All Search tips (11) All topics

Link