I tried to execute delete as per many previous discussions occurred find & delete

however my attempts lead to different experience.

find . -type d -name "koko" -exec rm -rf {} \;

deletes the folder named koko but give me false alarm

find: ./koko: No such file or directory

what is supposively going wrong at my terminal.

I am using tcsh , and -delete switch with find doesn't work well.

here is the snapshot of workout done


If you use the -prune option as suggested in this answer, the error message doesn't occur.

Quoting from the above answer,

Use -prune on the directories that you're going to delete anyway to tell find not to bother trying to find files in them.


mkdir koko
cd koko
touch file{1,2}
cd ..
find . -type d -name "koko" -prune -exec rm -rf {} \;

After I execute the above find command, I get the prompt without any error. However, if I do not use the -prune option, I get the same error as you mention.

  • it worked fine as you suggest. find definition made it more clear – JigarGandhi Dec 2 '14 at 16:16
  • @JigarGandhi, glad it resolved your issue. :) – Ramesh Dec 2 '14 at 16:25

The problem is that find has found a directory, it matches your selection and then the command is executed. However, find wants to do what comes naturally, and that's recursing through a directory tree, but the directory it's just found has disappeared! Hence the error message.

You can work around this by supplying the --depth option, which means process each directory's contents before the directory itself. The manpage also mentions that the -delete option also implies this option, which is for the above reason.

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.