How to get a 10-byte length random string in bash
Posted on In QAHow to get a 10-byte length random string in bash.
Use this script to get a 10-byte string of letters:
tr -dc "[:alpha:]" < /dev/urandom | head -c 10
You can also get a string of letters or numbers:
tr -dc "[:alnum:]" < /dev/urandom | head -c 10
Or printable characters except space:
tr -dc "[:graph:]" < /dev/urandom | head -c 10
Or printable characters including space:
tr -dc "[:print:]" < /dev/urandom | head -c 10