Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: listing/deleting empty directories recursively



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