This is driving me a bit batty. I now if must be a simple matter but I cant find anything that references it.
I have a housekeeping script that searches for some huge dump directories then removes them using rm -rf.
find ./ -name 'ab' -exec rm -rf {} \;
This works but always returns the following
find: `./ab': No such file or directory
This would be ok on an "on the fly" delete, but I have this as part of a larger backup script and this message returns as something for us to error check.
Is there a way for me to delete a directory without getting this message returned?
How do you mean that find cant find the file? Before the rm -rf it must find it in order to delete it, right? It just seems that after the rm -rf it tries to find the file again and then presents the error.
Why am I getting the error when the file is clearly there??
When -depth is not used, the find command visits a directory before its contents. So, when find sees ab, it performs the -exec and afterwards tries to descend into ab to see what's there. That's where the error message comes from.