26

I would like to recursively find all the files for which a script which accepts a file as an argument returns a non-zero value. Any idea how to do this using 'find' or a similar tool?

38

find’s -exec action can be used for this:

find . \! -exec yourscript {} \; -print

will print the names of all files for which yourscript fails.

-exec can be used in this way to turn appropriate external commands into find tests.

  • 8
    Equivalently, using -o (or): find . -exec yourscript {} \; -o -print. – John Kugelman Apr 8 at 19:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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