Find a file inside a zip
I'm Brian Duff, a Scot 🏴 living and working in the California Bay Area. I've worked, written, and presented about technology since the 90s.
My journey with computers started in the 80s while playing Manic Miner and hacking BASIC on the Sinclair ZX Spectrum.
I'm currently a Distinguished Engineer at LinkedIn. Previously, I was a Principal Engineer at Google. Before Google, I worked on Engineering Effectiveness at Twitter, and then before that, led Mobile Developer Experience at Facebook. Prior to that, I worked at Google leading projects and teams on a large number of things for many years, including Nearby, Cloud SQL, Bazel, and Google+. My first job out of university was at Oracle, where I built IDE frameworks for a living.
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