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

Root Boy Jim rbj at icst-cmr.arpa
Wed May 4 06:33:06 AEST 1988


   From: Juergen Wagner <gandalf at csli.stanford.edu>
   Date: 28 Apr 88 22:29:13 GMT

	   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

Csh needs a few other operators, such as a test for symbolic links.

   Juergen "Gandalf" Wagner,		   gandalf at csli.stanford.edu
   Center for the Study of Language and Information (CSLI), Stanford CA

	(Root Boy) Jim Cottrell	<rbj at icst-cmr.arpa>
	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
	I represent a sardine!!



More information about the Comp.unix.questions mailing list