dotfiles2/base/bin/genpw
2024-05-10 17:07:23 -07:00

18 lines
257 B
Bash
Executable file

#!/bin/sh
if [ "$1" = "-n" ] ; then
template='[:alnum:]'
shift
else
template='[:alnum:]+=\-_'
fi
if [ -z "$1" ] ; then
echo "usage: $0 [-n] length" >&2
exit 1
fi
LC_ALL=C tr -dc "$template" </dev/urandom | \
fold -w$1 | head -n1