cat /dev/urandom
is always a fun way to create scrolling characters on your display, but produces too many non-printable characters.
Is there an easy wa
There are already several good answers on how to base64 encode random data (i.e. cat /dev/urandom | base64
). However in the body of your question you elaborate:
... encode [urandom] on the command-line in such a way that all of it's output are readable characters, base64 or uuencode for example.
Given that you don't actually require parseable base64 and just want it to be readable, I'd suggest
cat /dev/urandom | tr -dC '[:graph:]'
base64
only outputs alphanumeric characters and two symbols (+ and / by default). [:graph:]
will match any printable non-whitespace ascii, including many symbols/punctuation-marks that base64 lacks. Therefore using tr -dC '[:graph:]'
will result in a more random-looking output, and have better input/output efficiency.
I often use < /dev/random stdbuf -o0 tr -Cd '[:graph:]' | stdbuf -o0 head --bytes 32
for generating strong passwords.