Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
test if a parameter is numeric
- X-seq: zsh-users 11182
- From: zzapper <david@xxxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: test if a parameter is numeric
- Date: Fri, 9 Feb 2007 17:05:15 +0000 (UTC)
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- Organization: SuccessTheory
- Sender: news <news@xxxxxxxxxxxxx>
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