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

Re: test if a parameter is numeric



On Sun, Feb 11, 2007 at 02:08:40AM +0100, DervishD wrote:
>     If you can use "expr", you can do it with "expr", using simple
> regexes. OK, not the fastest method, but should do and should do it
> pretty fast. I use this approach in my "mobs" project. Being bulletproof
> using almost-portable shell scripting is, at least, tricky. And probably
> impossible, for what I've seen...
> 
>     Raúl Núñez de Arenas Coronado

Sorry maybe I'm missing something, but if you need to match more than
one digit, what's wrong with:

[[ "$1" == [0-9][0-9]* ]]

Which I think is more portable?

Lydgate



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