I run this command on a Unix box:
find . name CVS -exec rm -fr {} \;
I wanted to delete any file called CVS
within any directory from the current directory and it deleted everything.
Fortunately all I had to do to recover was check out again from CVS. Imagine if I specified /
as the starting directory!
I think the reason is that I used name
instead of -name
. I just rerun it as
find . -name CVS -exec rm -fr {} \;
And it seem to work fine. What exactly happens if name
is used as opposed to -name
?
find … -exec echo rm -fr {} \;
.echo
part, which just prints the command that would otherwise have been executed. The elipsis…
are just Gilles' way to not repeat the other parameters in the example. So, the full version would befind . name CVS -exec echo rm -fr {} \;