From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13216 invoked from network); 19 Nov 2005 12:49:20 -0000 X-Spam-Checker-Version: SpamAssassin 3.1.0 (2005-09-13) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00, FORGED_RCVD_HELO autolearn=ham version=3.1.0 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 19 Nov 2005 12:49:20 -0000 Received: (qmail 52565 invoked from network); 19 Nov 2005 12:49:13 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 19 Nov 2005 12:49:13 -0000 Received: (qmail 28226 invoked by alias); 19 Nov 2005 12:49:06 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 9696 Received: (qmail 28216 invoked from network); 19 Nov 2005 12:49:05 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 19 Nov 2005 12:49:05 -0000 Received: (qmail 51534 invoked from network); 19 Nov 2005 12:49:05 -0000 Received: from viefep12-int.chello.at (HELO viefep20-int.chello.at) (213.46.255.25) by a.mx.sunsite.dk with SMTP; 19 Nov 2005 12:49:03 -0000 Received: from Dingo ([213.47.104.218]) by viefep20-int.chello.at (InterMail vM.6.01.04.04 201-2131-118-104-20050224) with ESMTP id <20051119124902.QPAF28648.viefep20-int.chello.at@Dingo> for ; Sat, 19 Nov 2005 13:49:02 +0100 From: Christian Taylor To: zsh-users@sunsite.dk Subject: Re: listing/deleting empty directories recursively Date: Sat, 19 Nov 2005 13:48:29 +0100 User-Agent: KMail/1.8 References: <20051119115653.GA329@imada.sdu.dk> <20051119115926.GB329@imada.sdu.dk> In-Reply-To: <20051119115926.GB329@imada.sdu.dk> MIME-Version: 1.0 Content-Disposition: inline Message-Id: <200511191348.29062.cht@chello.at> Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Thor Andreassen wrote: > > This should do the trick: > > > > for dir in `ls -ld **/*(/^F)`; do echo $dir > LOGFILE; rmdir $dir; done > > You should use double quotes (") around the dir variable if you have > dirnames with spaces (and some other chars), i.e. echo "$dir" and rmdir > "$dir". That probably wouldn't work, since ls -ld prints a whole lot of additional information that will be interpreted as directories to log and delete. It's far simpler to do away with ls: for dir in **/*(/^F); do print $dir >> LOGFILE; rmdir $dir; done or with the alternative syntax I really like: for dir (**/*(/^F)) { print $dir >> LOGFILE; rmdir $dir } As far as I can see, filenames generated this way are already quoted correctly, so spaces and special characters shouldn't be an issue. Christian