From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19451 invoked from network); 23 Oct 2003 15:44:36 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 23 Oct 2003 15:44:36 -0000 Received: (qmail 27762 invoked by alias); 23 Oct 2003 15:43:52 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 6731 Received: (qmail 27739 invoked from network); 23 Oct 2003 15:43:51 -0000 Received: from localhost (HELO sunsite.dk) (127.0.0.1) by localhost with SMTP; 23 Oct 2003 15:43:51 -0000 X-MessageWall-Score: 0 (sunsite.dk) Received: from [62.193.203.32] by sunsite.dk (MessageWall 1.0.8) with SMTP; 23 Oct 2003 15:43:51 -0000 Received: from DervishD.pleyades.net (212.Red-80-35-44.pooles.rima-tde.net [80.35.44.212]) by madrid10.amenworld.com (8.10.2/8.10.2) with ESMTP id h9NFho115489 for ; Thu, 23 Oct 2003 17:43:51 +0200 Received: from raul@pleyades.net by DervishD.pleyades.net with local (Exim MTA 2.05) id <1AChUj-0001zn-00>; Thu, 23 Oct 2003 17:35:25 +0200 Date: Thu, 23 Oct 2003 17:35:25 +0200 From: DervishD To: Zsh Users Subject: Finding empty directories Message-ID: <20031023153525.GB52@DervishD> Mail-Followup-To: Zsh Users Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit User-Agent: Mutt/1.4i Organization: Pleyades User-Agent: Mutt/1.4i Hello all :) I want to test if a directory is empty or not and I've thought that I could test for the expansion of dirname/*(DN[1]). If this is an empty string, then the directory is empty, otherwise it has at least one file. Anyway I was wondering if is there a better way of doing that using just zsh code, with no external commands (I know I can do a 'find -type d -empty', for example, or 'ls | wc -l', etc...). I would like to test if a filename correspond to a dangling symlink, too. I can find dangling symlinks using **/*(-@), but if I just have a file listing, how can I test if a file is a dangling symlink or not? I've found that doing the following test: [[ -h file && ( -r file || -d file ) ]] will only return true for a symlink that really points to a file or a directory, and false otherwise, but I'm not sure if this is a proper way or if it will fail miserably on some obscure case :? In fact, I'm not sure if '-r' and '-d' follow symlinks by default :? Thanks in advance for your help ;) Raúl Núñez de Arenas Coronado -- Linux Registered User 88736 http://www.pleyades.net & http://raul.pleyades.net/