Hi All
In a script, I want a user to enter 4 characters, these can be a mix of letters (uppercase and lowercase) and numbers.
In this example $var represents what the user has entered.
eg $var can be A9xZ, 3DDL, bbHp .........etc
I need to check that the user has only entered characters so I added the following code:
# Check for invalid characters
echo "$var" | grep [^a-zA-Z0-9] >/dev/null
if [ $? -eq 0 ]
then
echo "$var is not valid."
fi
This appears to work ok unless the user enters a wildcard character.
For example if the user enters bin*, the script expands the * and makes $var equal to all files in the current directory which start with bin.
So $var is "bin bindir binary"
My question is how can I process $var literally as "bin*" in the above grep statement?
Thanks for your help
Helen
