# Generate a random password
# $1 = number of characters; defaults to 32
# $2 = include special characters; 1 = yes, 0 = no; defaults to 1
function randpass() {
[ "$2" == "0" ] && CHAR="[:alnum:]" || CHAR="[:graph:]"
cat /dev/urandom | tr -cd "$CHAR" | head -c ${1:-32}
echo
}
Once you stored it and read into memory you will be able to generate pw like this:
# randpass 16 0 MkyzmsLYJVIom8B9 # randpass 32 1 g&^>K1:40Y*&R$C(o;q!XS1,2j^_WvRr
enjoy!