How do I use zgrep to look for content in archived files matching a given filename pattern?

2.4k Views Asked by At

Suppose I have two tar.gz files

a1.tar.gz
a2.tar.gz

and each archive contains many files, including a file called

target.txt

How do I search for BLAH in target.txt in both of these archives using zgrep without searching all of the other files in each archive?

If I try

zgrep -a BLAH *.tar.gz

then that searches all files in each archive, and if I try

zgrep --include=target.txt -a BLAH *.tar.gz

then I get

zgrep: --include=target.txt: option not supported
0

There are 0 best solutions below