[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Checking if directory is empty in postrm



On Tue, Nov 17, 1998 at 03:05:08PM +0100, Richard Braakman wrote:
> Chris Waters wrote:
> > if [ "$(echo * .*)" = "* . .." ] ; then echo empty dir; fi
> 
> Brilliant. :-)
> 
> It has only one flaw.  *cough*
> 
> % mkdir emptydir; cd emptydir
> % touch *
> % if [ "$(echo * .*)" = "* . .." ] ; then echo empty dir; fi
> empty dir
> 
> *evil grin*

That's easy enough to fix.

if [ "$(echo * ? .*)" = "* ? . .." ] ; then echo REALLY empty dir; fi

*more evil grin*


Reply to: