-
Website
http://www.tech-recipes.com/ -
Original page
http://www.tech-recipes.com/rx/756/checking-if-a-variable-is-a-number-in-ksh/ -
Subscribe
All Comments -
Community
-
Top Commenters
-
davak
83 comments · 1 points
-
danishbacker
9 comments · 1 points
-
flexinfo
11 comments · 1 points
-
bej
4 comments · 1 points
-
dimithri
5 comments · 1 points
-
-
Popular Threads
-
Windows 7: How to Prevent the Mouse from Waking your PC
15 hours ago · 1 comment
-
Outlook 2010: Turn Off Attachment Preview
1 week ago · 1 comment
-
Gmail: How to Send SMS Messages Without Using Email
2 weeks ago · 2 comments
-
Windows 7 – Prevent Live Messenger from Opening at Start Up
1 week ago · 1 comment
-
Symfony: Drop Down List Box Without Submit Button
3 weeks ago · 1 comment
-
Windows 7: How to Prevent the Mouse from Waking your PC
You'll get FALSE!
From expr's man page:
EXIT STATUS
[...]
0 if the expression is neither NULL nor 0
1 if the expression is either NULL or 0
[...]
I'd use "-eq 2" instead of "-ne 0."
Thanks anyway, good tip.
G_VAR=$1
if [[ $G_VAR = +([0-9]) ]]; then
print "G_VAR is a number"
else
print "G_VAR is not a number"
fi