Here I stumbled on great intro into Bash scripting for NetOps by John Kristoff ” Introduction to Shell and Perl scripting for Network Operators” and could’t help but do it my way. Here it is, bash
script that generates random password of printable characters, up to 15 at least.
[bash]
#!/bin/bash
# usage: randompass.sh [n] [count] – n is number of characters in password
# to generate 9 by default, and count – number of passwords to generate, 1 by default
n=${1:-9}
counter=${2:-1}
for ii in `seq 1 $counter` ;do
dd count=1 bs=15 if=/dev/urandom 2>/dev/null |
od -a |
sed ‘2d’ |
sed ‘s/0000000 \(.*\)/\1/’ |
tr -d ‘ ‘ | cut -c 1-$n |
sed ‘s/\([a-z]\)/\U&/3’ |
sed ‘s/\([A-Z]\)/\l&/4’
done [/bash]
Download the script
Example.

randompass.sh 7 7

o&sOh~K
deL(HMd
dc23DBg
HK?S@iE
_$SL*Ad
si|}Del
%I-ba