#! /bin/bash # This simple script will generate a password with the following: # Uppercase Letter, Lowercase Letter, Number, Special Character # # Length of password is determined by a provided variable. # The default password length is 8 characters. rpassLN='a-zA-Z0-9' rpassS='!-_@#$%^&*()+{}:<>?=' echo ; echo "Generate random passwords." ; echo echo "How many? Default = 4" ; read rpassA echo "How long? Default = 8" ; read rpassL if [[ -z $rpassA ]] then rpassA=4 fi if [[ -z $rpassL ]] then rpassL=8 fi echo ; cat /dev/urandom | tr -dc "$rpassS$rpassLN" | fold -w ${rpassL} | head -n ${rpassA}