-----Original Message-----
From: fedora-list-bounces(a)redhat.com
[mailto:fedora-list-bounces@redhat.com] On Behalf Of Paul Howarth
Sent: Tuesday, June 27, 2006 12:34 PM
To: For users of Fedora Core releases
Subject: Re: Bash problems?
Ben Stringer wrote:
> On Tue, 2006-06-27 at 12:03 +0200, Tomas Larsson wrote:
>> Dear group.
>> How do I do to, within a scrip, check if a directory I
empty or not.
>> Cant find a way to do this in a simple way.
>
> DIR_CONTENTS=`ls $DIR`
> if [ "$DIR_CONTENTS" == "" ]
> then
> echo "$DIR is empty"
> else
> echo "$DIR contains:"
> echo $DIR_CONTENTS
> fi
I'd use "ls -A $DIR" there rather than "ls $DIR" so as to
spot files with names starting with a dot.
Paul.
Thanks all, however for some reason 'ls $DIR' didn't work.
$(ls $DIR) did the job.
Now, I want to exlude sub-dirs in the ls command?
With best regards
Tomas Larsson
Sweden
Verus Amicus Est Tamquam Alter Idem