#!/bin/bash PATTERN="A-Za-z0-9_" if [ -z "$1" ]; then N=16 else N=$1 fi echo $(cat /dev/urandom | LC_ALL=C tr -cd "$PATTERN" | head -c $N)