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.