From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22047 invoked from network); 8 Feb 2002 22:59:54 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 8 Feb 2002 22:59:54 -0000 Received: (qmail 16723 invoked by alias); 8 Feb 2002 22:59:40 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 4667 Received: (qmail 16711 invoked from network); 8 Feb 2002 22:59:39 -0000 Date: Fri, 8 Feb 2002 22:59:37 +0000 (GMT) From: Bart Schaefer Sender: lantern@brasslantern.com To: Steve Talley cc: zsh-users@sunsite.dk Subject: Re: Reverse the order of an array? In-Reply-To: <20020208153514.C10334@thpppt> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Fri, 8 Feb 2002, Steve Talley wrote: > How can I easily reverse the order of an array in zsh? Depends what you mean by "easily." > I was hoping that something like > > osvers=($osvers[{$#osvers..1}]) > > would work, but no luck. Array "slices" in zsh only have start and end points, and are always in ascending order by numeric position in the array. So you can't do this purely with parameter expansion in the general case. This works: for ((i=$#osvers; i>0; --i)) { osvers[i*2]=($osvers[1]); shift osvers }