Shell script to validate password strength

walden systems, geeks corner, programming, languages, developer, redmine, backup, shell, unix, bash, ksh, svn, rsync, gzip, respository, svn, subversion, erase, secure, files, rm, password
Shells read input up to an unquoted newline and then execute it. An unquoted backslash followed by a newline are discarded and cause the shell to wait for more input. The backslash and newline are discarded before the shell tokenizes the string, so long lines can be split anywhere outside of single quotes, even in the middle of command names and variable names.

Here is an example script to validate password strength. We will use common password strengths such as the following:

     - Length – minimum of 8 characters.
     - Contain both letters and numbers.
     - Include both upper and lower case letters. 

The following script will check for the above conditions and will report it as a weak password

 1 #Password Validation Script
 2 echo "Enter your password"
 3 read password
 4 len="${#password}"
 5 
 6 if test $len -ge 8 ; then
 7     echo "$password" | grep -q [0-9]
 8      if test $? -eq 0 ; then
 9            echo "$password" | grep -q [A-Z]
10                 if test $? -eq 0 ; then
11                     echo "$password" | grep -q [a-z]   
12                       if test $? -eq 0 ; then
13                        echo "Strong Password"
14                    else
15                        echo "Weak Password - No lower case letters."
16                    fi
17             else
18                echo "Weak Password - No upper case letters." 
19             fi
20      else
21        echo "Weak Password - No numbers in your password."   
22      fi
23 else
24     echo "Weak Password -> Password length should have at least 8 characters."
25 fi