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 way to encode it on the command-line in such a way that all of its output are readable characters, base64 or uuencode for example.
Note that I prefer solutions that require no additional files to be created.
So, what is wrong with
?
Fixed after the first attempt didn't actually work... ::sigh::
BTW-- Many unix utilities use '-' in place of a filename to mean "use the standard input".
What about something like
Which gives (lots of) stuff like
Or, without the (useless) cat+pipe :
(Same kind of output ^^ )
EDIT : you can also user the
--wrap
option ofbase64
, to avoid having "short lines" :This will remove wrapping, and you'll get "full-screen" display ^^
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:Given that you don't actually require parseable base64 and just want it to be readable, I'd suggest
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 usingtr -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.You can do more interesting stuff with BASH's FIFO pipes:
A number of folks have suggested
cat
ting and piping throughbase64
oruuencode
. One issue with this is that you can't control how much data to read (it will continue forever, or until you hit ctrl+c). Another possibility is to use thedd
command, which will let you specify how much data to read before exiting. For example, to read 1kb:Another option is to pipe to the
strings
command which may give more variety in its output (non-printable characters are discarded, any runs of least 4 printable characters [by default] are displayed). The problem withstrings
is that it displays each "run" on its own line.(of course you can replace the entire command with
if you don't want it to ever stop).
If you want something really funky, try one of: