Skip to main content
7 events
when toggle format what by license comment
Oct 26, 2017 at 11:01 comment added Joey Baruch this does not work for me. it only deletes the deepmost leaf (SUBDIR3 in this case)
Sep 19, 2014 at 2:30 comment added jamadagni People, go for go2null's much more succinct answer below! Can't understand why SE gives priority to accepted answers rather than answers with most upvotes in displaying the answers below the question. The OP accepts the best answer available at his time of choosing, but later on much better answers can come which the community upvotes, no? (Of course, this is something for meta...)
Dec 19, 2013 at 23:05 comment added idbrii Possibly alternative is to use + instead of ; so you batch remove directories. Since you're doing it depth-first the children will still be removed before the parents (possibly dependent on your version of rmdir/bash and reliant on rmdir not deleting nonempty directories). This works for me in bash on cygwin: mkdir -p a/b/c/d ; find a -depth -type d -exec rmdir {} +
Nov 8, 2011 at 14:43 comment added l0b0 Consider if you have a tree (directories only) foo/bar/baz. Unless you use -depth, it will try to delete foo first, fail, and you'll end up with foo/bar after running.
Nov 8, 2011 at 14:26 comment added Abhishek A Why is -depth option necessary? find . -type d -empty -exec rmdir "{}" \; should also work.... right?
Nov 8, 2011 at 13:16 vote accept gsklee
Nov 8, 2011 at 5:26 history answered Steve Juranich CC BY-SA 3.0