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

Re: listing/deleting empty directories recursively



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