From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16505 invoked from network); 18 Sep 2006 17:18:23 -0000 X-Spam-Checker-Version: SpamAssassin 3.1.5 (2006-08-29) 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.5 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 18 Sep 2006 17:18:23 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 27999 invoked from network); 18 Sep 2006 17:18:13 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 18 Sep 2006 17:18:13 -0000 Received: (qmail 11353 invoked by alias); 18 Sep 2006 17:18:02 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 10735 Received: (qmail 11275 invoked from network); 18 Sep 2006 17:18:01 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 18 Sep 2006 17:18:01 -0000 Received: (qmail 25763 invoked from network); 18 Sep 2006 17:18:01 -0000 Received: from smtpout0137.sc1.cp.net (HELO n068.sc1.cp.net) (64.97.136.137) by a.mx.sunsite.dk with SMTP; 18 Sep 2006 17:17:56 -0000 Received: from sc (82.26.164.211) by n068.sc1.cp.net (7.2.069.1) id 450519B6000E7FEC for zsh-users@sunsite.dk; Mon, 18 Sep 2006 17:17:54 +0000 Received: from chazelas by sc with local (Exim 3.36 #1 (Debian)) id 1GPMki-0001ei-00 for ; Mon, 18 Sep 2006 18:17:52 +0100 Date: Mon, 18 Sep 2006 18:17:52 +0100 From: Stephane Chazelas To: zsh-users@sunsite.dk Subject: Re: OT: How to list all but the last item Message-ID: <20060918171752.GA4980@sc> Mail-Followup-To: zsh-users@sunsite.dk References: <20060918.183959.74746293.Meino.Cramer@gmx.de> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20060918.183959.74746293.Meino.Cramer@gmx.de> User-Agent: Mutt/1.5.6i Sender: Stephane Chazelas On Mon, Sep 18, 2006 at 06:39:59PM +0200, Meino Christian Cramer wrote: > Hi, > > may be this is a very stupid question...and may be I am blind... > But... > > I want to contruct a loop like > > for i in `` > do > ${i} > done > > and should return a list of items matched by a regexp > or another kind of qualifier and skipping the last item. > > Example: > > ls -rtlc * | > > would return every item in a directory exept the newest one. -c is to sort of the file change-status time. You want file modification time, it's ls -rtl. And it should be ls -rtl | ... Or ls -rtld -- * | ... > Is there any way to accomplish with something fitting in on > a commandline??? ls -tl | tail +2 ls -trl | sed '$d' Also: ls -trld -- *(om[2,-1]) Also: IFS=$'\n\n' lines=( $(cmd) ) for line in "${(@)lines[1,-2]}"; do ...; done -- Stéphane