From: Stephane Chazelas <Stephane_Chazelas@yahoo.fr>
To: zzapper <david@tvis.co.uk>
Cc: zsh-workers@sunsite.dk, zsh-users@sunsite.dk
Subject: Re: Substituting all but a trailing digit/number
Date: Fri, 13 Jul 2007 14:36:55 +0100 [thread overview]
Message-ID: <20070713133654.GA7301@sc.homeunix.net> (raw)
In-Reply-To: <Xns996C91E6E2BD1zzappergmailcom@80.91.229.5>
On Fri, Jul 13, 2007 at 01:22:56PM +0000, zzapper wrote:
> Peter Stephenson <pws@csr.com> 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
next prev parent reply other threads:[~2007-07-13 13:37 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <Xns996C883213985zzappergmailcom@80.91.229.5>
[not found] ` <200707131248.l6DCmHAI018710@news01.csr.com>
2007-07-13 13:22 ` zzapper
2007-07-13 13:36 ` Stephane Chazelas [this message]
2007-07-13 13:41 ` zzapper
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070713133654.GA7301@sc.homeunix.net \
--to=stephane_chazelas@yahoo.fr \
--cc=david@tvis.co.uk \
--cc=zsh-users@sunsite.dk \
--cc=zsh-workers@sunsite.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).