Re: Checking if directory is empty in postrm
On Sun, 15 Nov 1998, Marcus Brinkmann wrote:
> I need something that returns an error code if the directory is empty but
> does return 0 if it is non-empty.
$ dirname="whatever_you_want_to_check"
$ count=$(ls -A1 $dirname 2>/dev/null | wc -l)
$ echo $count
I love shell... BTW, you need the /dev/null just in case the directory
doesn't exist.
HTH,
tony
tmancill@us.lhsgroup.com | Si jeunesse savait, si vieillesse pouvait.
WAN Admin - LHS Group | (Henri Estienne)
| #include <standard_disclaimer.h>
Reply to: