How To Check Uppercase String in Bash
We want to check if the string is uppercase. But the real difficulty is using bash. Bash have the ability to check this with ~ operator.
- password is ou bash variable that holds string
$ if [[ $password =~ [A-Z] ]] ; then
echo "Lower"; fi
- We use if else control statement.
- The logic lines $password =~ [A-Z] . We provide a regex and check our variable with ~ operator.
- After check we print “Upper” or “Lower” according the situation