views:

21

answers:

3

I'm wanting to recursively search my maven repository (an n folder deep heirachy of jars) for a specific class inside an unknown jar.

jar -tvf myJar.jar | grep ClassIWant.class works great for a known jar but I'm having problems piping/chaining bash commands to achieve a recursive search.

Any hints much appreciated.

Related: http://stackoverflow.com/questions/1682130/bash-find-file-in-archive-from-command-line

+2  A: 

Bash 4+

shopt -s globstar
for file in **/*.jar
do
  jar -tvf "$file" | grep ....
done

<4++

find /path -type f -name "*.jar" | while read -r FILE
do
     jar -tvf "$FILE" | grep ....
done
ghostdog74
Thanks, I'm running 3.2.
mds
then use find.. see edit
ghostdog74
+1  A: 
find -name \*.jar | xargs -n1 -iFILE sh -c "jar tvf FILE | sed -e s#^#FILE:#g" | grep classIWant\\.class | cut -f1 -d:
gawi
A: 

Post already exists. Solved here http://stackoverflow.com/questions/1500141/find-a-jar-file-given-the-class-name Thanks for the alternatives.

mds