[ALUG] How to check a directory is empty (probably in bash)?
Eur Ing Chris Green
cl at isbd.net
Wed Feb 21 11:42:10 GMT 2007
What's the simplest (and/or most concise) way to check for an empty
directory?
I can't just do a rmdir as I need to check three directories are empty
before I can do anything drastic (like removing the directory). Not
to mention that for one application of this I don't want to remove the
empty directory anyway.
As you've probably guessed this is to check if a maildir mailbox is
empty - to do this you need to check if all three subdirectories of
the maildir are empty.
I can see various rather clumsy ways of doing it but nothing neat and
elegant. A Google search didn't turn up much either, just some rather
arcane zsh ways of doing it which were arcane enough to be zsh only I
suspect.
I might get carried away and write a little 'C' utility do do it if
nothing sensible turns up.
--
Chris Green
More information about the main
mailing list