Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: listing/deleting empty directories recursively
- X-seq: zsh-users 9701
- From: zzapper <david@xxxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: listing/deleting empty directories recursively
- Date: Sat, 19 Nov 2005 17:07:04 +0000
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <tfrtn1dt9nf26m1rka6b9kg3bmcoa2evs4@xxxxxxx> <200511191057.25776.cht@xxxxxxxxx> <103un195cji6u17l0kj1ijkvfj2vn9o3r5@xxxxxxx> <1051119160931.ZM19308@xxxxxxxxxxxxxxxxxxxxxxx>
- Sender: news <news@xxxxxxxxxxxxx>
On Sat, 19 Nov 2005 16:09:31 +0000, wrote:
>On Nov 19, 11:28am, zzapper wrote:
>} Subject: Re: listing/deleting empty directories recursively
>}
>} >ls -ld **/*(/^F)
>} >
>} >Christian
>}
>} Now I'd like to rm those directories, and log which ones were deleted.
>
>On a GNU-ish system?
>
> rmdir --verbose **/*(/^F)
>
>You can work out the stderr redirections yourself.
>
>Of course you realize that this only finds/removes empty leaf directories.
>Every time you remove a directory you might discover that its parent has
>also become empty. For that reason you might be better off doing a depth-
>first traversal attempting to remove *all* directories, and simply allow
>rmdir to fail if the directory isn't empty.
>
> rmdir --verbose **/*(/od)
I presume this can be xarg?
eg
print **/*(/od) | xargs -n1 -t rmdir
The disadvantage of this is that it produces a flood of warning messages which may prevent you
spotting something untoward.
--
zzapper
Success for Techies and Vim,Zsh tips
http://SuccessTheory.com/
Messages sorted by:
Reverse Date,
Date,
Thread,
Author