9 randstr - Generate random string from a given set of characters and with a given length.
13 randstr <LENGTH> [<CHARS>]
17 B<CHARS> is a character set expression, see tr(1).
18 Default B<CHARS> is C<[a-zA-Z0-9_]>
37 charset
='[a-zA-Z0-9_]'
43 cat /dev
/urandom |
tr --delete --complement "$charset" |
{ read -r -n $length str
; printf %s
"$str"; }