Relational operator

Hi guys ,

 
if a=12345678 i need to check that "a" 
less than 8 char
greater than 8 char
equal to 8 char
contain only numeric.

I done the above with seperate if condition to check and print the proper echo statement according to the result.i.e more than 8 char/lessthan etc..
can i able to check all the condtions in one if using OR operator and echo the proper output.
Anybody pls help me out.

 
OS:SUNOS
script:shell scripting

Yes, you can do so. Check the man page of the test -command and have a look for the "-o" and "-a" options.

I hope this helps.

bakunin

len=`echo "$a" | awk '{print length}'`
if [ $len -lt 8 ]
then
 echo "less than 8"
elif [ $len -gt 8 ]
then
 echo "greater than 8"
elif [ -z `echo "$a" | tr -d '[0-9]'` ]
then
 echo "8 digits"
else
 echo "8 characters"
fi