Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!zaphod.mps.ohio-state.edu!van-bc!ubc-cs!uw-beaver!stowe.cs.washington.edu!pauld From: pauld@stowe.cs.washington.edu (Paul Barton-Davis) Newsgroups: comp.unix.questions Subject: Re: testing if a directory is empty (OOOPS!) Message-ID: <1991Apr16.173314.22085@beaver.cs.washington.edu> Date: 16 Apr 91 17:33:14 GMT References: <1991Apr15.195513.17840@beaver.cs.washington.edu> Sender: news@beaver.cs.washington.edu (USENET News System) Reply-To: pauld@cs.washington.edu (Paul Barton-Davis) Organization: Computer Science & Engineering, U. of Washington, Seattle Lines: 53 In article meissner@osf.org (Michael Meissner) writes: >In article <1991Apr15.195513.17840@beaver.cs.washington.edu> >pauld@cs.washington.edu (Paul Barton-Davis) writes: > [ my stupid idea deleted ] > >It still isn't any reason to fail. Off of the top of my head, the >following should work: > > [ "`cd $1; echo .[^.] .??* *`" = ".[^.] .??* *" ] >-- >Michael Meissner email: meissner@osf.org phone: 617-621-8861 >Open Software Foundation, 11 Cambridge Center, Cambridge, MA, 02142 > >Considering the flames and intolerance, shouldn't USENET be spelled ABUSENET? I may be wrong, but it seems regrettably not. From the man page for csh(1): The sequence `[...]' matches any one of the characters enclosed. Within `[...]', a pair of characters separated by `-' matches any character lexi- cally between the two. and from sh(1): [ ... ] Matches any one of the characters enclosed. A pair of char- acters separated by - matches any character lexically between the pair. These shell's don't know about the "[^" convention, and indeed: # echo .[^.] .. # echo .[^f] echo: No Match Your guess is as good as mine. What will work, for 7-bit systems anyway, is: echo .[^@--/-~]* * This matches ALL dots files except . and ... Unfortunately, my csh (Ultrix 4.1) doesn't handle the inclusion of ascii 127 (DELETE) in this list very graciously, and if you have non-ASCII (> code 127) chars in any dot file file name, this will also break. I increasingly feel that the "rmdir; if [ $? ..." approach is the best way to crack this. -- Paul Barton-Davis UW Computer Science Lab ``to shatter tradition makes us feel free''