Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have constructed an elaborate 500+ character command with many arguments and switches to autosign multiple PDF documents.

I'm using JSignPDF and I'd like to use it's batch mode including the current directory and subdirectories.

The relevant part of the command I'm having trouble with is:

java -jar ../jsignpdf-1.4.3/JSignPdf.jar *.pdf -a

...which of course works great for all PDF files in the current directory. How can I make it so it picks up all .pdf files in all the subdirectories as well?

I've tried a few things which haven't worked... novice and not even worth mentioning...things like -r (obviously would-/did-n't work).

I'm wondering if this is a simple answer or in need of some awk magic, if that would even be valid. Any help is greatly appreciated.

share|improve this question
add comment

1 Answer

up vote 6 down vote accepted

With zsh or ksh93 -G, you could do:

java -jar ../jsignpdf-1.4.3/JSignPdf.jar ./**/*.pdf -a

You could do the same with fish or bash -O globstar, but beware that those may traverse symlinks when descending the directory tree (fixed in bash 4.3).

Otherwise, if the list of files is not too big, you could do:

find . -name '*.pdf' -exec sh -c '
  exec java -jar ../jsignpdf-1.4.3/JSignPdf.jar "$@" -a' sh {} +

But beware find may try to split the list and run several sh commands to try and overcome a limit on the command line size.

share|improve this answer
    
Both solutions worked beautifully! Thank you very much, very helpful. –  TryTryAgain Jan 31 '13 at 0:20
add comment

Your Answer

 
discard

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.