In conjunction with steeldriver's collation link, the solution is to use sets as defined in man tr
.
Also, a good reference for [[
vs [
Wooledge, GLOBS and why the following code may still fail with only [
1 #! /bin/bash
2
3 echo -e "Enter any character: \c"
4 read -rN 1 value
5 echo
6
7 case $value in
8 [[:lower:]] )
9 echo You have entered a lower case alphabet;;
10 [[:upper:]] )
11 echo You have entered an upper case alphabet;;
12 [[:digit:]] )
13 echo You have entered a number;;
14 [?] )
15 echo You have entered a special character;;
16 [*] )
17 echo Unknown value;;
18 esac
From wooledge link above:
Ranges
Globs can specify a range or class of characters, using square
brackets. This gives you the ability to match against a set of
characters. For example:
[abcd] Matches a or b or c or d
[a-d] The same as above, if globasciiranges is set or your locale is C or
POSIX. Otherwise, implementation-defined.
[!aeiouAEIOU] Matches any character except a, e, i, o, u and their uppercase
counterparts
[[:alnum:]] Matches any alphanumeric character in the current locale (letter or
number)
[[:space:]] Matches any whitespace character
[![:space:]] Matches any character that is not whitespace
[[:digit:]_.] Matches any digit, or _ or .
For info on globasciiranges : Bash Reference Manual