Unix – Why doesn’t the ‘find’ work like I expect using -exec


I'm trying to remove all the .svn directories from a working directory.

I thought I would just use find and rm like this:

find . -iname .svn -exec 'rm -rf {}' \;

But the result is:

find: rm -rf ./src/.svn: No such file or directory

Obviously the file exists, or find wouldn't find it… What am I missing?

Best Solution

You shouldn't put the rm -rf {} in single quotes.

As you've quoted it the shell is treating all of the arguments to -exec it as a command rather than a command plus arguments, so it's looking for a file called "rm -rf ./src/.svn" and not finding it.


find . -iname .svn -exec rm -rf {} \;