I have the assignment to write a bash script to validate password strength and one of the requirements is: Include both the small and capital case letters. The Password variable is the input, of course, one of the requirements to validate the password is that the password has to contain upper case letters, lower case letters, and numbers. It would be enough even if only one letter is upper case and one is the lower case but for that don't I need to go over the string with for loop and compare each letter to upper case and lower case? Only one case of both of them would be enough.
if [[ $PASSWORD == ${PASSWORD,,} ]] &&
[[ $PASSWORD == ${PASSWORD^^} ]]; then
valid=true
else
valid=false
fi
It always will give me false.
Can anyone please help me, thank you!
Your test is always false except if " PASSWORD
" do not contains letters!
#! /bin/bash
...
if [[ "$PASSWORD" =~ [a-z] ]] && [[ "$PASSWORD" =~ [A-Z] ]]; then
valid=true
else
valid=false
fi
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.