Empty Directory? (Was: Picking a character from a word)

Mario Dorion mdorion at cmtl01.UUCP
Sun May 8 12:15:57 AEST 1988


In article <13241 at brl-adm.ARPA>, rbj at icst-cmr.arpa (Root Boy Jim) writes:
> 	   set nonomatch
> 	   if ( ! -e $dir/* ) echo $dir is empty.
> 
> Didn't work under 4.3 BSD. How about a two-step solution?
> 
> 	ls -A $dir > /tmp/$$
> 	if ( -z /tmp/$$ ) echo directory empty

Wouldn't
        if [ `ls -a $dir | wc -w` -eq 2 ]  \* for . and .. *\
        then echo $dir is empty
        fi
work ?????

BTW: what does "set nonomatch" do ???

-- 
     Mario Dorion              | ...!{rutgers,uunet,ihnp4}!     
     Frisco Bay Industries     |            philabs!micomvax!cmtl01!mdorion
     Montreal, Canada          |
     1 (514) 738-7300          | I thought this planet was in public domain!



More information about the Comp.unix.questions mailing list