still struggling with this shell script (Password Validation), I've search for the solution, but I'm still not find the proper solution.#!/bin/shecho enter the passwordread passwordlen=${#password}if test $len -ge 8 ; then    echo $password | grep -q [A-Z]    echo $password | grep -q [a-z]    echo $password | grep -q [0-9]    if test $? -eq 0 ; then      echo Strong password    else      echo Weak password    fielse    echo password lenght should be greater than or equal 8fiWere the result from this script as following :# ./password.sh enter the password12345678Strong password >> Not as I expected which is should be weak passwordWhere is my fault? 
Help me understand why test $? -eq 0 is true even when I expect it to be false
shell script
Your grep invocations are being ran sequentially and $? is only equal to the last grep in your script. You'll want to use something like this after each grep:retCodes=0echo $password | grep -q [A-Z]retCodes=$(($retCodes + $?))echo $password | grep -q [a-z]retCodes=$(($retCodes + $?))echo $password | grep -q [0-9]retCodes=$(($retCodes + $?))The if [[ $retCodes -eq 0 ]]; then ...