bash find with two commands in an exec ~ How to find a specific Java class within a set of JARs -
my use case want search collection of jars specific class file. more specifically, want search recursively within directory *.jar files, list contents, looking specific class file.
so have far:
find . -name *.jar -type f -exec echo {} \; -exec jar tf {} \;
this list contents of jar files found recursively. want put grep
within seconed exec
because want second exec
print contents of jar grep
matches.
if put pipe , pipe grep afterward, like:
find . -name *.jar -type f -exec echo {} \; -exec jar tf {} \; | grep $classname
then lose output of first exec
, tells me class file (the name of jar file not match class file name).
so if there way exec
run 2 commands, like:
-exec "jar tf {} | grep $classname" \;
then work. using grep $(...)
in exec
command wouldn't work because need {}
find
take place of file found.
is possible? (also open other ways of doing this, command line preferred.)
i find difficult execute multiple commands within find-exec, grab results find , loop around results.
maybe might help?
find . -type f -name *.jar | while read jarfile; echo $jarfile; jar tf $jarfile; done
Comments
Post a Comment