Hi all,
As part of a Bourne shell script I'm writing, I need to check the user's input to make sure that it meets requirements (in this case, only alphabetic characters).
The way I'm doing it at the moment is reading the variable, then using a case statement to print an error if the input is incorrect.
Code:
read word
case $word in
[a-zA-Z]+) echo "Valid" ;;
*) echo "Error" ;;
esac
I'm guessing that the case statement doesn't support the regular expression [a-zA-Z]+ , any suggestions on other ways I could go about it?
Thanks.