So I was debugging some code the other day and I quickly found myself in a situation where I had to look for a class file that was located in one of the many millions of jar files that are there in my maven cache. My immediate reaction was
“Ugh, this is going to be loads of effort and is going to take ages!”.
Luckily, quick one minute google found the following command:
find /home/manthan/.m2 -name '*.jar' -type f|while read f; do p="$(tar tf $f|egrep awesome)"; [ -n "$p" ] && echo -e "$f\n$p" ; p=""; done
awesome.class is the file I’m looking for in all files (indicated with
-type f option) with extension
jar found in