How can I remove all run-*.achilles directories in all of my subdirectories under Linux?

I tried find /path -name run-*.achilles -type f -delete but it doesn't work.


Several issues here:

  1. You should quote * to prevent shell globbing.
  2. -type f tells find you want files.
  3. find -delete won't delete non-empty directories. See this question. Adjusted solution from one of the answers there:

    find /path -path '*/run-*.achilles/*' -delete
    find /path -type d -name 'run-*.achilles' -empty -delete

It's not perfect, the first line will match .../run-a/b.achilles/.... I think. This command should match better:

find /path -type d -name 'run-*.achilles' -exec rm -rf {} +

It uses rm -rf, so be careful with it.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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