How do I tell when a directory is empty in a script?
Bernd Felsche
bernie at metapro.DIALix.oz.au
Thu Apr 18 15:47:35 AEST 1991
I suppose this might have been mentioned before.... If you can write
to the parent, then try to rmdir it. rmdir will fail (to the best of
my knowledge/experience) if there's anything in the directory.
rmdir $dir && mkdir $dir || echo $dir not empty 1>&2
Good enough? Thought not!
--
Bernd Felsche, _--_|\ #include <std/disclaimer.h>
Metapro Systems, / sale \ Fax: +61 9 472 3337
328 Albany Highway, \_.--._/ Phone: +61 9 362 9355
Victoria Park, Western Australia v Email: bernie at metapro.DIALix.oz.au
More information about the Comp.unix.questions
mailing list