Date: Thu, 18 May 2000 07:20:26 -0400 (EDT) From: Trevor Johnson <trevor@jpj.net> To: Dan Larsson <dl@tyfon.net> Cc: questions@FreeBSD.ORG Subject: Re: Howto determine if directory is empty Message-ID: <Pine.BSI.4.21.0005180713170.17138-100000@blues.jpj.net> In-Reply-To: <NEBBJANJCNNAKCPFKHHFCELOCDAA.dl@tyfon.net>
next in thread | previous in thread | raw e-mail | index | archive | help
> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSI.4.21.0005180713170.17138-100000>
