GNU bug report logs - #45924
RFE: rmdir -r: recursively remove [empty] directories under the target.

Previous Next

Package: coreutils;

Reported by: L A Walsh <coreutils <at> tlinx.org>

Date: Sun, 17 Jan 2021 00:31:01 UTC

Severity: wishlist

Full log


View this message in rfc822 format

From: Bernhard Voelker <mail <at> bernhard-voelker.de>
To: Paul Eggert <eggert <at> cs.ucla.edu>, L A Walsh <coreutils <at> tlinx.org>, 45924 <at> debbugs.gnu.org
Subject: bug#45924: RFE: rmdir -r: recursively remove [empty] directories under the target.
Date: Mon, 18 Jan 2021 17:08:51 +0100
On 1/17/21 11:18 PM, Paul Eggert wrote:
> find DIR -depth -type d -exec rmdir {} +

find(1) can also find empty directories and delete them:

  $ find DIR -type d -empty -delete

FWIW: -delete implies -depth.

If one wants to see what empty directories have been found (and get deleted),
just put a -print in there:

  $ find DIR -type d -empty -print -delete

The above works with GNU find (as both -empty and -delete are GNU extensions).

Have a nice day,
Berny




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.