简体   繁体   中英

Grep recursively through zipped files

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM