Checking character type

Basic types / Character type

c1="A"
[[ "$c1" == [[:alpha:]] ]] && isLetter=true || isLetter=false
[[ "$c1" == [[:digit:]] ]] && isNumber=true || isNumber=false
#isLetter is true
#isNumber is false

c2='$'
[[ "$c2" == [[:punct:]] ]] && isPunct=true || isPunct=false
#isPunct is true

#quoted, the variable is plain text inside the pattern;
#an empty c2 would match any list, hence the -n check
symbolList='@#$%^&*'
[[ -n "$c2" && "$symbolList" == *"$c2"* ]] && isInList=true || isInList=false
#isInList is true

echo "isLetter is $isLetter"
echo "isNumber is $isNumber"
echo "isPunct is $isPunct"
echo "isInList is $isInList"