From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6863 invoked from network); 11 Sep 2003 01:06:39 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 11 Sep 2003 01:06:39 -0000 Received: (qmail 10265 invoked by alias); 11 Sep 2003 01:06:28 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 19061 Received: (qmail 10249 invoked from network); 11 Sep 2003 01:06:25 -0000 Received: from localhost (HELO sunsite.dk) (127.0.0.1) by localhost with SMTP; 11 Sep 2003 01:06:25 -0000 X-MessageWall-Score: 0 (sunsite.dk) Received: from [4.64.232.255] by sunsite.dk (MessageWall 1.0.8) with SMTP; 11 Sep 2003 1:6:25 -0000 Received: (from schaefer@localhost) by candle.brasslantern.com (8.11.6/8.11.6) id h8B16NF07490 for zsh-workers@sunsite.dk; Wed, 10 Sep 2003 18:06:23 -0700 From: Bart Schaefer Message-Id: <1030911010623.ZM7489@candle.brasslantern.com> Date: Thu, 11 Sep 2003 01:06:23 +0000 In-Reply-To: <20030910203429.GA354@DervishD> Comments: In reply to DervishD "Getting rid of temporaries..." (Sep 10, 10:34pm) References: <20030910203429.GA354@DervishD> <20030910223845.GA10805@lorien.emufarm.org> In-Reply-To: <20030910223845.GA10805@lorien.emufarm.org> Comments: In reply to Danek Duvall "Re: Getting rid of temporaries..." (Sep 10, 3:38pm) X-Mailer: Z-Mail (5.0.0 30July97) To: Zsh Subject: Re: Getting rid of temporaries... MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Sep 10, 10:34pm, DervishD wrote: } Subject: Getting rid of temporaries... } } I have a directory structure containing files whose names match } the expression '*.??.jpg'. } [...] I want to strip the number and the '.jpg' suffix from the names. } Now the question: how can I do this without using the temporary } parameter 'array' and, if possible, without 'uniq'. If you have the array, it's easy to do without uniq. To do it without the array begins to creep into the realm of "so difficult it's not worth bothering." The 'e' globbing flag gets you most of the way: print -l *.??.jpg(e['REPLY=${REPLY%.??.jpg}']) Of course, that uses the magic temporary $REPLY variable, so it hasn't really eliminated temporaries. On Sep 10, 3:38pm, Danek Duvall wrote: } } typeset -U array } array=( /directory/*/* ) } array=( ${^array%.<00-99>.jpg} ) } print -l $array This suggestion is on the right track, but it's not equivalent to Raul's original one, because your first assignment may match names that do not match *.<00-99>.jpg, which won't be modified by the second assignment. } will do what you want. The "typeset -U" makes $array discard duplicate } elements, but that requires the reassignment once the dups are gone I'm not sure what you mean by "requires the reassignment once the dups are gone". You have to strip the suffixes before zsh can tell what the duplicates are. } though it might be a nice candidate for yet another parameter expansion } flag. :) You mean like ${(u)...}, which is in 4.1.1-dev-* ... } The "^" turns on rcexpandparam for the expansion of $array, which means } that, as an array, each element is modified. That's not what rcexpandparam means. It means that, if the expansion is concatenated with other strings before and/or behind, then every element is individually so concatenated. You don't have any concatenation going on here, so the caret isn't needed. So we end up with, perhaps: typeset -U array array=( *.<00-99>.jpg(e['REPLY=${REPLY%.??.jpg}']) ) print -l $array