|
| From: | Bernhard Voelker |
| Subject: | bug#45924: RFE: rmdir -r: recursively remove [empty] directories under the target. |
| Date: | Mon, 18 Jan 2021 17:08:51 +0100 |
| User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 |
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
| [Prev in Thread] | Current Thread | [Next in Thread] |