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

test if a parameter is numeric



Hi embarassingly elementary but its Friday

I just want to test if a parameter is numeric

if [ "$1" -gt '0' ] && [ "$1" -lt '9' ]
then

this works but barfs (but does not exit) if $1 is non-numeric

So what's the proper way to do this pls!

hey just solved it

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

I'll post anyway just in case some poor chump googles for this one day

-- 
zzapper
http://successtheory.com/tips/ Vim, Zsh, MySQL Tips



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