Random Password Generator

I found this script on the web somewhere quite a while back. Kudos to the author and if I ever find it again I'll be sure to link to the original.

#!/bin/bash
 
path=/bin:/usr/bin:/usr/local/bin
 
pwdlen=$1
 
char=(
 a b c d e f g h i j k l m n o p q r s t u v w x y z 
 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 
 0 1 2 3 4 5 6 7 8 9 ! @ \# $ % ^ \&
)
 
max=${#char[*]}
 
for i in `seq 1 $pwdlen`
do
        let rand=${RANDOM}%${max}
        str="${str}${char[$rand]}"
done
echo $str

Use like this: (numeric value determines password length)

$ ./pwdgen.sh 16
U1CRy2Ymc9n54YXa

Change pwdlen=$1 to pwdlen=10 to generate a password of 10 characters in length every time.

$ ./pwdgen.sh 
Y$Ue@QMwHP
Burtronix Banner W3C Banner