I am searching for a .class file inside a bunch of jars.
jar tf abc.jar
works for one file. I tried
find -name \"*.jar\" | xa
You need to pass -n 1
to xargs
to force it to run a separate jar
command for each filename that it gets from find
:
find -name "*.jar" | xargs -n 1 jar tf
Otherwise xargs
's command line looks like jar tf file1.jar file2.jar...
, which has a different meaning to what is intended.
A useful debugging technique is to stick echo
before the command to be run by xargs
:
find -name "*.jar" | xargs echo jar tf
This would print out the full jar
command instead of executing it, so that you can see what's wrong with it.