I have 348 zip files and I want to find a file that is in one of the zip files, unzip -l
doesn't work with wild cards?
How can I list content of all .zip
files and grep
through the merged list of all files contained in the zips?
I have 348 zip files and I want to find a file that is in one of the zip files, unzip -l
doesn't work with wild cards?
How can I list content of all .zip
files and grep
through the merged list of all files contained in the zips?
Using
zipinfo
is a fine solution here. However, in general whenever you want to apply a command to a list of files and the command doesn’t accept a list of files, you can use afor
loop:If the file you are searching for has spaces in it like:
your file
, in the grep regular expression you need to escape every space with a backslash likegrep "\.zip\|your\ file"
.You can use
zipinfo
. It is included in the default Ubuntu installation. Check the manual page for more info.For example, to look for a pattern
setup
in a bunch of zip files in current directory, use this command:To list the files in a zip archive you can use the following command.
To grep a compressed archive you should use the compressed archive utilities built to work with that type of archive format.
For zip archives:
For tar archives:
There are a few other tools that work with archives as well. You can pipe the out put into grep to do the same thing.
Or you can use the search functionality of these tools