Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

10
  • 41
    I have seen advice to always run -type after -name in find commands, since calls to stat to get the type are expensive. I just tried it myself on a fairly large bunch of files, and it seems to be true: running find . -name 'foo' -type d took 19 secs, while find . -type d -name 'foo' took 32 secs. So about 50% longer time to run -type first. Commented Mar 16, 2015 at 16:37
  • 15
    i've been using this command for years, but on Mac now i get errors saying those directories do not exist. Even though it does delete them. I never saw messages before. Commented Dec 23, 2015 at 8:51
  • 2
    Same as @chovy. Is there a way to get rid of these messages? Commented Apr 23, 2016 at 15:32
  • 4
    @chovy @clément That is because find wants to see in that folder for other matches, while it's removing the folder at the same time. ~I don't know yet how to fix this.~ Dirty fix: find . -name "folder-to-delete" -print0 | xargs -r0 -- rm -r Commented Jul 20, 2016 at 12:02
  • 9
    @chovy @Clément I think the -depth argument fixes this: find . -depth -name ".svn" -type d -exec rm -r "{}" \; Commented Jul 27, 2016 at 7:57