I have a list of zip files containing themselves multiple files.
Like this :
| archive-1.zip
| file1.xml
| file2.xml
| file3.xml --> contains myStringToFind
| file4.xml
| archive-2.zip
| file1b.xml
| file2b.xml
| archive-3.zip
| file1c.xml
| file2c.xml
My goal is to find a string across the files within those zip archives. What I've achived so far is that :
for i in archive*.zip;do unzip -c "$i" 2>/dev/null|grep -l myStringToFind;
if test $? -eq 0; then echo $i;fi;
done|grep archive
Output: archive-1.zip
.With this I'm able to find the archive containing my string.
The next step is to find the name of the file within the archive, but I'm unable to find a way to do this.
My expected output would be archive-1.zip file3.xml
Any help would be appreciated.
zipgrep
forzip
archives andzgrep
forgz
archives easily. Please have a look at https://unix.stackexchange.com/a/18557/254422 – binarysta Sep 11 '20 at 10:37