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 ]

then

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

fi

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

Leave a Reply