Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to run a command on every file within a directory (recursively) that matches a pattern. I need the filename of each item that matches for the command however. This is how far I've got:

find . -name '*.jar'

That gives me all the files I'm interested in. Now, I need to run the following command on all those files:

jarsigner -keystore ***** -storepass ****** $FILENAMEHERE

How do I reference the individual items in the output of find, for the command?

share|improve this question
up vote 6 down vote accepted

If jarsigner takes only one file name at a time, use either

find . -iname '*.jar' | xargs -l jarsigner -keystore ***** -storepass ******


find . -iname '*.jar' -exec jarsigner -keystore ***** -storepass ***** {} \;
share|improve this answer
Yes, xargs makes things more readable! However the man says the '-l' option is deprecated: '-L 1' should do the same. – cYrus Aug 19 '10 at 9:23

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.