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

Re: listing/deleting empty directories recursively



On Sat, Nov 19, 2005 at 11:28:15AM +0000, zzapper wrote:
> On Sat, 19 Nov 2005 10:57:25 +0100,  wrote:
> 
> >> ls -ld *(/^F)
> >>
> >> Will list any empty directories, but only for one level of subdirectories,
> >> how to make it delete empty directories at any level.
> >
> >ls -ld **/*(/^F)
> >(will list empty directories at any level in the current working directory)
> >
> >Christian
> Thanx works just dandy,
> Now I'd like to rm those directories, and log which ones were deleted. 

This should do the trick:

for dir in `ls -ld **/*(/^F)`; do echo $dir > LOGFILE; rmdir $dir; done

-- 
mvh
Thor Andreassen



Messages sorted by: Reverse Date, Date, Thread, Author