From owner-freebsd-questions Thu May 18 4:20:38 2000 Delivered-To: freebsd-questions@freebsd.org Received: from blues.jpj.net (blues.jpj.net [204.97.17.146]) by hub.freebsd.org (Postfix) with ESMTP id 682BA37B982 for ; Thu, 18 May 2000 04:20:33 -0700 (PDT) (envelope-from trevor@jpj.net) Received: from localhost (trevor@localhost) by blues.jpj.net (right/backatcha) with ESMTP id e4IBKQi18754; Thu, 18 May 2000 07:20:26 -0400 (EDT) Date: Thu, 18 May 2000 07:20:26 -0400 (EDT) From: Trevor Johnson To: Dan Larsson Cc: questions@FreeBSD.ORG Subject: Re: Howto determine if directory is empty In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG > I'm currently using this: > > if [ -d $mydir -a `cd $mydir; ls -la | wc -l | awk '{print $1}'` -eq 2 ] > then > echo 'empty' > else > echo 'not empty (or not a directory)' > fi > > Is there a better way ( preferrably shorter ) to do it? With GNU find you can do: find wherever -type d -empty to get a list of empty directories. -- Trevor Johnson http://jpj.net/~trevor/gpgkey.txt To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message