Brian Duff
Duffblog

Follow

Duffblog

Follow

Find a file inside a zip

Brian Duff's photo
Brian Duff
ยทJun 5, 2009ยท

1 min read

Brutally simple shell script I often use to find a class file that I know exists somewhere in a directory tree full of jar files (but generally useful for finding files somewhere in a directory tree of zips):

#!/bin/bash

for zip in $*
do
echo $zip
for file in $(unzip -Z -1 $zip)
do
echo "$zip:$file"
done
done

I put this in a file called zipdump, then do things like this:

find -name "*.jar" | xargs zipdump | grep SomeClass

And get:

./some/random/path/foo.jar:com/google/whatever/SomeClass.class

ย 
Share this