18 lines
257 B
Bash
Executable file
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
|