Paul Ruane wrote: > Apologies, I did not copy the mailing list on part of the discussion. > > On 14 February 2012 20:48, Jim Meyering <[email protected]> wrote: >>>>I should have asked up front, >>>>Have you considered the --ignore-fail-on-non-empty option? > >>>Um, no! That's perfect. Not sure why I didn't see that before: either > my eyes skipped it or I disregarded it but it's there, as plain as > day. >>> Actually it's not quite perfect I have to do 'rmdir -p >>> --ignore-fail-on-non-empty a/b a/c a/d a/e' rather than my proposed >>> 'rmdir -d a' but it'll do at a pinch. > >> or this: >> rmdir -p --ig a/[bcde] > > This does solve the problem but means I have to list all of the leaf > nodes of the branch I wish to remove. I still can't help but think > there should be a --descendents option to allow a branch (of empty > directories) to be removed more simply. The above would then simply > become: > > $ rmdir -d a > > Even if directories b, c, d and e have children themselves.
I suggest you use find. This does what you want, at least with GNU find: find a -depth -type d -empty -delete
