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

Re: test if a parameter is numeric



On Feb 9,  5:05pm, zzapper wrote:
}
} I just want to test if a parameter is numeric
} 
} if [[ "$1" == [0-9] ]]

Better:

  if [[ "$1" = <-> ]]

This is a zsh-ism, so it's not cross-shell portable, but the pattern <->
matches any string having any number of digits and only digits.



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