#!/bin/bash # Beforehand, do these things; # sudo apt install wamerican-large # egrep '^[a-z]{3,5}$' /usr/share/dict/words > ~/bin/words.txt # This gives a list of about 23,000 all lowercase words. # or, if you want things to all be the same length, use this; # egrep '^[a-z]{4}$' /usr/share/dict/words > ~/bin/words.txt Words=~/bin/words.txt # Minimum length of Pass Len=15 # If a number was passed as an argument, set length to it [[ ${1} == ?(-)+([0-9]) ]] && Len=${1} Count=1 # If two numbers are passed in, give a list of that many passphrases [[ ${2} == ?(-)+([0-9]) ]] && Count=${2} True=1 False=0 Sym='!@#$%^&*-_' Num='1234567890' SymCnt=${#Sym} NumCnt=${#Num} Loop=1 while [ ${Loop} -le ${Count} ] do TorF=$(( RANDOM % 2 )) First=$(shuf -n 1 ${Words}) String=${First^} while [ ${#String} -le ${Len} ] do if [ ${TorF} -eq ${True} ]; then TorF=${False} String+="${Sym:$(($RANDOM%${SymCnt})):1}" else TorF=${True} String+="${Num:$(($RANDOM%${NumCnt})):1}" fi This=$(shuf -n 1 ${Words}) String+=${This^} done echo ${String} ((Loop++)) done