Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: listing/deleting empty directories recursively
- X-seq: zsh-users 9699
- From: Stephane Chazelas <Stephane_Chazelas@xxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: listing/deleting empty directories recursively
- Date: Sat, 19 Nov 2005 15:59:44 +0000
- In-reply-to: <200511191348.29062.cht@xxxxxxxxx>
- Mail-followup-to: zsh-users@xxxxxxxxxx
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <tfrtn1dt9nf26m1rka6b9kg3bmcoa2evs4@xxxxxxx> <20051119115653.GA329@xxxxxxxxxxxx> <20051119115926.GB329@xxxxxxxxxxxx> <200511191348.29062.cht@xxxxxxxxx>
- Sender: Stephane Chazelas <stephane_chazelas@xxxxxxxx>
On Sat, Nov 19, 2005 at 01:48:29PM +0100, Christian Taylor wrote:
[...]
> for dir in **/*(/^F); do print $dir >> LOGFILE; rmdir $dir; done
>
> or with the alternative syntax I really like:
>
> for dir (**/*(/^F)) { print $dir >> LOGFILE; rmdir $dir }
>
> As far as I can see, filenames generated this way are already quoted
> correctly, so spaces and special characters shouldn't be an issue.
They will as you forgot the "-r" for print, and to mark the end
of options with "--" for both print and rmdir.
Moreover, note that that won't remove directories that only
contain empty directories, you may prefer:
zargs rmdir -- ./**/*(/od) 2> /dev/null
as rmdir won't remove non-empty dirs anyway.
--
Stéphane
Messages sorted by:
Reverse Date,
Date,
Thread,
Author