Another Random Password Script

I seem to do this sort of thing a lot.
Start out by installing the dictionary of your choice, I prefer the ‘Large American’ with;

sudo apt install wamerican-large

Then, if it doesn’t exist, create a ~/bin directory and move into it;

mkdir -p ~/bin
cd ~/bin

And create a list of shorter words;

grep -E -o '^[a-z]{2,5}$' /usr/share/dict/words > ~/bin/words.txt

Finally, type all of the below into a file called ~/bin/GenPass or copy and paste it, and then make it executable;

#!/bin/bash
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
# Beforehand, do these things;
# sudo apt install wamerican-large
# grep -E -o '^[a-z]{2,5}$' /usr/share/dict/words > ~/bin/words.txt

To make it executable, issue the following command;

chmod a+x ~/bin/GenPass

To run it, you should be able to just type ‘GenPass’ on a command line;

GenPass
Carbo#Shoot4Pairs

Or

GenPass 24
Gazes7Bifid&Joch3Sheld$Garum
 
GenPass 14 10
Imcnt7Talar&Inkle
Viper6Ender!Grype
Rheda2Birls^Didal
Popsy2Screw_Ramp
Pied8Rhein-Fbi8Fley
Valor#Azofy2Singe
Irate^Ofays9Aztec
Onces_Neuk0Busts
Gilpy!Tung5Lept
Nasal4Baloo&Aint
 
GenPass 15 21 | column
Cere_Clone3Saxes        Ulema!Jokes1Scala       Hide!Teres3Aglee
Owsen@Thowt4Ymca        Bdl-Alay7Lamm_Lour      Jello#Tsp1Dz&Lynch
Solus3Mani&Ogles        Bai7Sably_Bourr9Welts   Cakra5Woibe_Mysid
Tarse3Ample@Fares       Taper9Mirly&Plato       Prepg!Grunt1Ive-Immix
Dildo$Hols7Rived        Utile6Feedy@Gt5Soger    Fuage&Heaps6Jived
Bases*Porch0Cymol       Gnarr&Those9Jundy       Abash#Pocan4Trike
Wool8Mohos$Sluer        Daces0End-Aluta2Divan   Logos4Mensa#Lobs