Password length validation using bash

Shell Scripting

${#var}: Length of Variable’s Contents

This expansion returns the length of the expanded value of the variable:

read passwd

if [ ${#passwd} -lt 8 ]


printf “Password is too short: %d characters\n” “$#” >&2 exit 1


In case of any ┬ęCopyright or missing credits issue please check CopyRights page for faster resolutions.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.