how to set a variable to accept alpha-numeric characters?

I am working on a shell program that needs to accept alpha-numeric input (i.e., P00375); when I use a simple 'read' statement to read in the input (i.e., read LOG), I receive the message "p00375: bad number". How must I adjust my input statement to accept alpha-numerics?

Thanks!
Brent

Which Shell are you using?

I would think that the reason for the error you are receiving is not related to the read...read will take what it gets....are you actually doing something with the read in data after the read?

You can see here with bash shell

This is the script:

echo "Please enter a string: "
read thestring
echo "The string I have read in is $thestring"

And when it's run:

$ script1
Please enter a string:
P009988
The string I have read in is P009988

I'm using the Korn shell on my UNIX box. For some reason, I thought I had to treat an alphanumeric differently than a numeric; now that I have looked over my script, I noted what the problem was (a 'less than/greater than' limitation)...it works fine now. Thanks for shaking some sense into me! :slight_smile:

just to add some more info

as you said you script was cribbing when you did the comparison of the string, but finally did you solve the problem of comapring the string. If not, i have something for you

You can do a comparison of the strings for less than or greater than as follows

if [[ string1 > string2 ]]

i guess so far you have been using only
if [ string1 = string2 ] and hence your script is thru. but just in case you need the comparison for gr8er than or less than then use the [[ and ]]

rgds
penguin