string checking

please help me providing the code of checking a string pure numeric or not and pure alphanumeric or not

for checking numeric values use:

-eq equal to
-ne not equal to
-lt less than
-le less than or equal to
-gt greater than
-ge greater than or equal to

for string comparison use:

>
<

!=

for regex use:

[[

]]

let me know if u hav any confusion.

i cant get u....lets think str is a variable...how can i check it is pure numeric or not

try this:

if [[ $str == [0-9][0-9]* ]];then

echo "\$str has numeric value=$str"
else
echo "$str is not numeric"
fi

check to see if it passes a basic math test ;-)

i.e. something like expr:

#  expr hello + 1
expr: non-numeric argument

#  expr 2hello + 1
expr: non-numeric argument

#  expr 2 + 1
3

mix this with an if and you're away...

works with ksh and bash

if [[ ${str//[0-9]/} ]]; then
   print "ERROR: Not a numeric string"
fi

case construct

a=10
case $a in 
   *[!0-9]*) echo "not number";; 
esac