GNU bug report logs -
#45924
RFE: rmdir -r: recursively remove [empty] directories under the target.
Previous Next
Full log
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
Every once in a while, I want to remove what I believe to be
an empty directory tree, safely.
I wondered, why not have rmdir have a recursive option
that would remove all directories under a given directory,
presuming they were empty. That way I can try to remove
the tree, removing what it can, and only failing if it
ran into a file that prevented the removal.
I'd _at least_, have it do a depth-first removal and halt
with a ENOTEMPTY status if an rmdir failed to remove a
directory due to it not being empty.
So for dirs one,two,three + file dir 'two' next to three:
one-+two-+three
|-file
rmdir -r one would first remove
one/two/three,
then fail removing one/two because 'two wasn't empty'.
--- probably, I think adding a mode like "--failearly"
should also be available to have rmdir fail on the recursive
descent if it encountered non-dir while descending.
Yes, you could do it some other way, like by using 'find',
but since it is about removing directories, having the option
under rmdir would seem a natural place to put it.
Useful?
This bug report was last modified 3 years and 115 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.