Hi,
I want the user to enter only numeric values and also he should only enter
2 digits only ( eg 23 or 23 or 03 any 2 digits)
For the above purpose how should i declare my variable ?
integer value
if I read 03 in variable value then it gives me error ...also user can enter n number of digits ..how can i restrict it to only 2 digits ...
Thanks ...
zhou
August 9, 2006, 5:53am
2
Why not try to use the regular expressions?
It's just the thing for you.
i can use regular expressions to check whether entered string is numeric or character one ... but how can i restrict it to 2 or 3 digits only ?
vino
August 9, 2006, 6:20am
4
From man sh
read [-ers] [-u fd] [-t timeout] [-a aname] [-p prompt] [-n nchars] [-d
delim] [name ...]
-n nchars
read returns after reading nchars characters rather than
waiting for a complete line of input.
I couldnt find anything similiar for ksh. Hmm...
Or a more generalized way would be to see what this post holds - making a .sh wait for user input