Path: utzoo!attcan!uunet!husc6!bloom-beacon!mit-eddie!ll-xn!ames!umd5!brl-adm!adm!rbj@icst-cmr.arpa From: rbj@icst-cmr.arpa (Root Boy Jim) Newsgroups: comp.unix.questions Subject: Empty Directory? (Was: Picking a character from a word) Message-ID: <14421@brl-adm.ARPA> Date: 17 May 88 17:21:21 GMT Sender: news@brl-adm.ARPA Lines: 41 From: Mario Dorion In article <13241@brl-adm.ARPA>, rbj@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 ????? I suppose. BTW: what does "set nonomatch" do ??? I assume you must be running TPC UNIX, or you would have read the csh manual. Anyway, "mkdir x; cd x; set nonomatch; echo qaz*" echo's 'qaz*'. The variable `nonomatch' allows the echo to succeed instead of producing an error. Personally, I dislike both the name and the implementation. I would have called the variable `nullmatch' and returned the empty string. Now for some head scratching, what does `unset nonomatch' mean? :-) 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! (Root Boy) Jim Cottrell National Bureau of Standards Flamer's Hotline: (301) 975-5688 The opinions expressed are solely my own and do not reflect NBS policy or agreement My name is in /usr/dict/words. Is yours?