Getting variable length in Bourne Shell

I am writing a bourne shell application which accepts input from a user.  The value that is entered MUST be a three digit number.  What is the best (easiest) way to validate this variable ?
resedlarAsked:
Who is Participating?
 
jhanceConnect With a Mentor Commented:
Assuming your variable is $USERINPUT:

$LENGTH=`echo $USERINPUT | wc -m`


0
 
sethuCommented:
Thank You ! Thank You ! Thank You !

Both jhance's and sethu's solutions work the only difference is that using the "wc -m" gives the length of the string + 1, but for the application I am writing that only means that the returned value should equal 4 instead of 3.


0
All Courses

From novice to tech pro — start learning today.