Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!swrinde!elroy.jpl.nasa.gov!decwrl!world!kaspar!ires From: ires@kaspar.ires.com (Bruce R Larson) Newsgroups: comp.unix.questions Subject: Re: testing if a directory is empty (OOOPS!) Message-ID: <107@kaspar.ires.com> Date: 19 Apr 91 00:32:55 GMT References: <1991Apr15.195513.17840@beaver.cs.washington.edu> Organization: Integral Resources, Milton, MA Lines: 25 >In article < ... > pauld@cs.washington.edu (Paul Barton-Davis) writes: >| So it needs to be: >| >| [ "`cd $1 ; echo .??* *`" = ".??* *" ] In article < ... > meissner@osf.org (Michael Meissner) writes: > ... the following should work: > > [ "`cd $1; echo .[^.] .??* *`" = ".[^.] .??* *" ] Here's how I've checked for empty dirs #!/bin/sh if [ "`ls -la $1 | wc -l`" -eq 3 ]; then echo empty; fi NOTE: every "ls -l" I've used lists the "total" number of entries on its first line of output, hence the "3". Bruce -- Bruce R. Larson Integral Resources, Milton MA Internet: blarson@ires.com Uucp: ..!{world|uunet}!ires.com!blarson