Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: listing/deleting empty directories recursively
- X-seq: zsh-users 9696
- From: Christian Taylor <cht@xxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: listing/deleting empty directories recursively
- Date: Sat, 19 Nov 2005 13:48:29 +0100
- In-reply-to: <20051119115926.GB329@xxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <tfrtn1dt9nf26m1rka6b9kg3bmcoa2evs4@xxxxxxx> <20051119115653.GA329@xxxxxxxxxxxx> <20051119115926.GB329@xxxxxxxxxxxx>
Thor Andreassen wrote:
> > This should do the trick:
> >
> > for dir in `ls -ld **/*(/^F)`; do echo $dir > LOGFILE; rmdir $dir; done
>
> You should use double quotes (") around the dir variable if you have
> dirnames with spaces (and some other chars), i.e. echo "$dir" and rmdir
> "$dir".
That probably wouldn't work, since ls -ld prints a whole lot of additional
information that will be interpreted as directories to log and delete. It's
far simpler to do away with ls:
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.
Christian
Messages sorted by:
Reverse Date,
Date,
Thread,
Author