Reputation: 1550
I have a set of zip files with multiple levels of directories in them. I want to find some content from a text file in one of those directories which can be in any of the zip files. If the files are unzipped, I would use the following
grep -r 'pattern' path
I tried using zgrep
but it said that the option -r
isn't supported. Is there a way to grep through the zipped files?
Thanks in advance.
Upvotes: 1
Views: 5770
Reputation: 37023
Try with find command like:
find mydir -type f -name "*log.gz" -exec zgrep "pattern" {} \;
Above command will search for pattern in files named "*log.gz" residing in either mydir or sub directories within mydir.
Upvotes: 4