a question for you shell scripters
Mike Coleman
mkc+dated+1050115787.cd063e at mathdogs.com
Fri Mar 28 02:49:50 CST 2003
Jason Clinton <clintonj at umkc.edu> writes:
> How can I rmdir all subdirectories that have no files in them,
> recursively.
If you don't mind the half-assed error messages, you can just say
$ find . -depth -type d -exec rmdir {} ;
A more correct solution with GNU find would be
$ find . -depth -type d -empty -exec rmdir {} ;
Gerald's -links idea would usually work as well, but I think some bizarre
filesystems won't necessarily have '.' and '..' entries.
Mike
More information about the Kclug
mailing list