From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14436 invoked from network); 12 Jul 2004 12:43:27 -0000 Received: from odin.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.85) by ns1.primenet.com.au with SMTP; 12 Jul 2004 12:43:27 -0000 Received: (qmail 1615 invoked from network); 12 Jul 2004 12:46:16 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 12 Jul 2004 12:46:16 -0000 Received: (qmail 22689 invoked by alias); 12 Jul 2004 12:42:30 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 7684 Received: (qmail 22679 invoked from network); 12 Jul 2004 12:42:29 -0000 Received: from odin.dotsrc.org (HELO a.mx.sunsite.dk) (qmailr@130.225.247.85) by sunsite.dk with SMTP; 12 Jul 2004 12:42:29 -0000 Received: (qmail 32698 invoked from network); 12 Jul 2004 12:45:41 -0000 Received: from born.physik.uni-dortmund.de (129.217.160.155) by a.mx.sunsite.dk with SMTP; 12 Jul 2004 12:45:28 -0000 Received: by born.physik.Uni-Dortmund.DE (Postfix, from userid 1014) id 2B8E511386; Mon, 12 Jul 2004 14:41:44 +0200 (CEST) Date: Mon, 12 Jul 2004 14:41:44 +0200 From: Klaus Wacker To: ZSH User List Subject: Re: Maildir empty? Message-ID: <20040712124144.GO2860@born.physik.uni-dortmund.de> Reply-To: wacker@Physik.Uni-Dortmund.DE References: <20040712073705.GN2860@born.physik.uni-dortmund.de> <690.1089625465@trentino.logica.co.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <690.1089625465@trentino.logica.co.uk> User-Agent: Mutt/1.4i X-Spam-Checker-Version: SpamAssassin 2.63 on a.mx.sunsite.dk X-Spam-Level: X-Spam-Status: No, hits=-0.0 required=6.0 tests=BAYES_44 autolearn=no version=2.63 X-Spam-Hits: -0.0 On Mon, Jul 12, 2004 at 11:44:25AM +0200, Oliver Kiddle wrote: > Klaus Wacker wrote: > > Dear zsh, is there a zsh-internal way to find out whether a maildir is > > empty? Or more generally, whether a directory tree contains no > > files? The following test ($i is the pathname of the maildir): > > > > if [[ $(echo $i/*/* | wc -w) -eq 0 ]] > > Does this do what you want: > if [ -z $i/*/*([1]) ] > > You need to use the single brackets so that the $i/*/* is treated as a > filename expansion. The ([1]) part makes sure that only one file is > expanded. > Thank you, that works. > Are you sure you didn't mean $i/**/* > You need to use **/ to search a whole directory tree. > For the general case I would probably need something like `$i/**/*(.)'. However, for maildirs, `$i/*/*' is what I need. Each maildir contains exactly three subdirectories named tmp, new and cur, and they contain the mail files, one per message. -- Klaus Wacker wacker@Physik.Uni-Dortmund.DE Experimentelle Physik V http://www.physik.uni-dortmund.de/~wacker Universitaet Dortmund Tel.: +49 231 755 3587 D-44221 Dortmund Fax: +49 231 755 4547