Reputation: 1
#!/bin/sh
echo "Enter a name"
read name
case "$name" in
*[!\ a-zA-Z]*) echo "Can contain only alphabets" >/dev/tty
continue;;
*) echo "Good entry" ;;
esac
Upvotes: 1
Views: 59
Reputation: 785108
This expression:
*[!\ a-zA-Z]*
Has !
at the start which does negation of all characters or ranges present inside [...]
. In this case it means anything that is
a-z
A-Z
Also note that escaping is for space next to \
not for the preceding !
to avoid word splitting.
Upvotes: 1