* Re: Substituting all but a trailing digit/number [not found] ` <200707131248.l6DCmHAI018710@news01.csr.com> @ 2007-07-13 13:22 ` zzapper 2007-07-13 13:36 ` Stephane Chazelas 0 siblings, 1 reply; 3+ messages in thread From: zzapper @ 2007-07-13 13:22 UTC (permalink / raw) To: zsh-workers; +Cc: zsh-users 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? -- zzapper http://www.rayninfo.co.uk/vimtips.html ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Substituting all but a trailing digit/number 2007-07-13 13:22 ` Substituting all but a trailing digit/number zzapper @ 2007-07-13 13:36 ` Stephane Chazelas 2007-07-13 13:41 ` zzapper 0 siblings, 1 reply; 3+ messages in thread From: Stephane Chazelas @ 2007-07-13 13:36 UTC (permalink / raw) To: zzapper; +Cc: zsh-workers, zsh-users 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 ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Substituting all but a trailing digit/number 2007-07-13 13:36 ` Stephane Chazelas @ 2007-07-13 13:41 ` zzapper 0 siblings, 0 replies; 3+ messages in thread From: zzapper @ 2007-07-13 13:41 UTC (permalink / raw) To: zsh-workers; +Cc: zsh-users > Also, why are you using ls? > > Why not simply > > gvim -p *(.om[1,$num]) > THNX Stephane I can give no rational answer!! -- zzapper http://www.rayninfo.co.uk/vimtips.html ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-07-13 13:42 UTC | newest] Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- [not found] <Xns996C883213985zzappergmailcom@80.91.229.5> [not found] ` <200707131248.l6DCmHAI018710@news01.csr.com> 2007-07-13 13:22 ` Substituting all but a trailing digit/number zzapper 2007-07-13 13:36 ` Stephane Chazelas 2007-07-13 13:41 ` zzapper
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).