0

I'm using bash shell. I have a group of JAR files in directories at different levels

> find . -name "*.jar"
/tmp/jars/META-INF/lib/jackson-datatype-jdk8.jar
/tmp/jars/lib/my-custom.jar
...

I would like to see if any of these JAR files contains a properties file whose file name matches "test-*.properties". I would prefer not to unzip each JAR file and search through its contents. Is there a way I can figure this information out?

1 Answer 1

1

Something will need to poke around inside the archive, though this can be done with an archive listing command such as unzip -l rather than having to extract all the files:

find . -name \*.jar -exec sh -c \
  'jar --list --file={} | grep -q '\''test-.*\.properties'\'' && printf "%s\n" {}' \;

Maybe unzip -l might be faster but harder to parse? jar seemed more sluggish to get itself up off disk for me.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .