Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: OT: How to list all but the last item
- X-seq: zsh-users 10735
- From: Stephane Chazelas <Stephane_Chazelas@xxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: OT: How to list all but the last item
- Date: Mon, 18 Sep 2006 18:17:52 +0100
- In-reply-to: <20060918.183959.74746293.Meino.Cramer@xxxxxx>
- Mail-followup-to: zsh-users@xxxxxxxxxx
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <20060918.183959.74746293.Meino.Cramer@xxxxxx>
- Sender: Stephane Chazelas <stephane_chazelas@xxxxxxxx>
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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author