I've a multiple jar directory in which I would like to locate some classes. I found a solution to see if a Class exists with the following command :
find -name "*.jar" | xargs -n 1 jar tf | grep 'myClass'
The problem is that I can't see in which jar
it is located.
I'm looking for a solution to display the filename in my terminal. My current output is like that :
[user@server lib]$ find -name "*.jar" | xargs -n 1 jar tf | grep 'RollOn'
com/ventyx/utils/logutils/rolling/RollOnDemandAppender.class
Any suggestions?
Best Answer
With GNU
grep
:Or use awk for instance:
You can also use
bsdtar
(asjar
files arezip
files andbsdtar
supports them) to do the matching by itself (allowing you to have a more verbose output with files metadata without running the risk ofgrep
matching on that metadata), though you'd still need something likegrep
to insert the filename: