Saturday, May 4, 2024
 Popular · Latest · Hot · Upcoming
18
rated 0 times [  18] [ 0]  / answers: 1 / hits: 38765  / 3 Years ago, tue, july 20, 2021, 2:27:17

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?


More From » grep

 Answers
7

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 a for loop:



for file in *.zip; do
unzip -l "$file"
done
| grep ".zip|setup"


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 like grep ".zip|your file".


[#35132] Wednesday, July 21, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
tialmes

Total Points: 14
Total Questions: 108
Total Answers: 102

Location: Oman
Member since Thu, Jun 16, 2022
2 Years ago
;