Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Substituting all but a trailing digit/number
- X-seq: zsh-users 11619
- From: Stephane Chazelas <Stephane_Chazelas@xxxxxxxx>
- To: zzapper <david@xxxxxxxxxx>
- Subject: Re: Substituting all but a trailing digit/number
- Date: Fri, 13 Jul 2007 14:36:55 +0100
- Cc: zsh-workers@xxxxxxxxxx, zsh-users@xxxxxxxxxx
- In-reply-to: <Xns996C91E6E2BD1zzappergmailcom@xxxxxxxxxxx>
- Mail-followup-to: zzapper <david@xxxxxxxxxx>, zsh-workers@xxxxxxxxxx, zsh-users@xxxxxxxxxx
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <Xns996C883213985zzappergmailcom@xxxxxxxxxxx> <200707131248.l6DCmHAI018710@xxxxxxxxxxxxxx> <Xns996C91E6E2BD1zzappergmailcom@xxxxxxxxxxx>
On Fri, Jul 13, 2007 at 01:22:56PM +0000, zzapper wrote:
> Peter Stephenson <pws@xxxxxxx> wrote in news:200707131248.l6DCmHAI018710
> @news01.csr.com:
>
> > zzapper wrote:
> >>
> >> I want to generalise top3 into top4,top5..etc
> >>
> >> But how could I get filter just the trailing number (in VIM I would use
> >> memory)
> >
> > Use
> >
> > num=${(M)0%%<->}
> >
> > The (M) tells the shell to substitute the matched part instead of
> > removing the matched part.
> Thanks Peter,
> And If I wanted to anchor the number to the end?
[...]
%% matches at the end, as much as possible.
You could also do
num=${0##*[!0-9]}
(remoes everything up to the rightmost non-digit).
That even happesns to be POSIX.
Also, why are you using ls?
Why not simply
gvim -p *(.om[1,$num])
--
Stéphane
Messages sorted by:
Reverse Date,
Date,
Thread,
Author