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

Re: listing/deleting empty directories recursively



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)



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