Linux – How to search for strings in a file which in turn is in an archive


I can search through a number of files for a particular string by pipelining 'grep' and 'find' commands.

Now, I have some 10 zip files each of which has archived a lot of text files. Is there any way I could search for a string in all text files archived in all those zip files without extracting the zip files?

Best Answer

  • unzip -c \*.zip | grep yourtext

    You could use some regexes in the grep command to finetune the string matching

    Based on the comments below, zgrep would be a better option.