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

Re: Substituting all but a trailing digit/number



zzapper wrote:
> 
> I want to generalise top3 into top4,top5..etc
> 
> function top3()
> {
> # description : vi 3 newest files
> file=$0
> num=${file//[[:alpha:]]/}
> gvim.exe -p $(l\s *(.om[1,$num])) &
> }
> 
> In the above substitution I get the "number" by stripping out the alphas 
> which is kind of a trick
> 
> 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.

-- 
Peter Stephenson <pws@xxxxxxx>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


To access the latest news from CSR copy this link into a web browser:  http://www.csr.com/email_sig.php

To get further information regarding CSR, please visit our Investor Relations page at http://ir.csr.com/csr/about/overview



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