Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: OT: How to list all but the last item



From: Stephane Chazelas <Stephane_Chazelas@xxxxxxxx>
Subject: Re: OT: How to list all but the last item
Date: Mon, 18 Sep 2006 18:17:52 +0100

> 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 `<cmd>`
> >  do
> >    <do something> ${i}
> >  done
> > 
> >  and <cmd> should return a list of items matched by a regexp
> >  or another kind of qualifier and skipping the last item.
> > 
> >  Example:
> > 
> >  ls -rtlc * | <???what???>
> > 
> >  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
> 

Hi Stephane,

 thanks a lot for your reply! :)
 
 Now I have many solutions to choose from :))

 Keep hacking!
 mcc



Messages sorted by: Reverse Date, Date, Thread, Author