I often use the command

cat /dev/urandom | strings --bytes 1 | tr -d '\n\t ' | head --bytes 32


to generate pseudo-random passwords. This doesn't work with /dev/random.

Specifically


cat /dev/urandom | strings --bytes 1 | tr -d '\n\t ' produces output
cat  /dev/random | strings --bytes 1 produces output
cat  /dev/random | strings --bytes 1 | tr -d '\n\t  ' does not produce output


NB: When using /dev/random you may have to wiggle your mouse or press keys (e.g. ctrl, shift, etc.) to generate entropy.

Why does the last example not work? Does tr have some kind of large internal buffer that /dev/urandom fills quickly but /dev/random doesn't?

P.S. I'm using CentOS 6.5

cat /proc/version
Linux version 2.6.32-431.3.1.el6.x86_64 (mockbuild@c6b10.bsys.dev.centos.org) (gcc version 4.4.7 20120313 (Red Hat 4.4.7-4) (GCC) ) #1 SMP Fri Jan 3 21:39:27 UTC 2014



Question: Clustering algorithm and distance function for sets
Answer: I would start with distances such as proposed by James Li. They are sometimes known as fingerprint distances. Then, in my experience, it can be a good idea to use graph clustering, although this may depend on the number of features that you have. If this is large and dimensionality is thus large, and if 'set intersection' models data proximity well, then graph clustering is in my opinion the best approach. If the number of features is limited, graph clustering can still work well, but one should also consider the option of comparing feature vectors directly and use an algorithm such as OPTICS - perhaps you have already done that.