What is the diff between the following two approach ?

find /calc -type f -delete
find /calc -type f  -exec rm -f {} +

my target is to remove any jar file/s under calc folder

any prefered of one of the options?

  • I update the question so rm -f – yael Feb 26 at 17:50

Given the tag, there's no difference. The -delete option will turn on the -depth option, so files may get removed in a different order but the result will be the same. The -delete option will only remove one file at a time while the -exec ... {} + option will remove multiple files at a time, but still the same files will be removed.

Beyond that, -delete is not yet a POSIX-specified option, so for cross-platform compatibility you may prefer the -exec habit.

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.