Brian Duff
Duffblog

Duffblog

Find a file inside a zip

Brian Duff's photo
Brian Duff
·Jun 5, 2009·

1 min read

Subscribe to my newsletter and never miss my upcoming articles

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