« Remote control repair | Home | Ten years of Sylpheed »
August 9, 2012
Reproducible random ordering from "sort -R"
Random discovery for the day (actually yesterday, but never mind): "sort -R", which randomises the order of lines in its input, uses a crytographic random number generator seeded using numbers which include its PID and the time. It's the same random number generator as used by "shred": ISAAC.
So, if you need to get the same random order of lines each time, as I did for a test script, you need to provide your own source of "random" numbers. Any old binary file will do, for example:
$ sort -R --random-source=/bin/ls
So, if you need to get the same random order of lines each time, as I did for a test script, you need to provide your own source of "random" numbers. Any old binary file will do, for example:
$ sort -R --random-source=/bin/ls
Leave a comment