Take a peek inside .jar files!

jar tf is a very useful command if we just want to peek into a jar. For example, I had a recent requirement of scanning several jars to look for Hibernate *.cfg.xml files. Naturally, it would have been tedious had I had to open each jar to check. The following simple script (using jar tf) came to the rescue.

for f in `find . -name '*.jar'`;do echo --$f--;jar tf $f | grep -n cfg.xml;done

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.