summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPádraig Brady <P@draigBrady.com>2015-02-09 20:58:47 +0000
committerPádraig Brady <P@draigBrady.com>2015-02-11 00:31:39 +0000
commit430bda373361addf16962301b3afaf1b19ee9fc8 (patch)
treea7ce3cade74f55cd6f6d069535aa0a641f0ab60c
parent99f76aec8a7e74f2e1622b74b1011fac6f677f4e (diff)
downloadcoreutils-430bda373361addf16962301b3afaf1b19ee9fc8.tar.xz
doc: give an example of using a seed for random operations
* doc/coreutils.texi (Random sources): Give an example using openssl, generating a reproducible arbitrary amount of randomly distributed data, given a seed value.
-rw-r--r--doc/coreutils.texi15
1 files changed, 15 insertions, 0 deletions
diff --git a/doc/coreutils.texi b/doc/coreutils.texi
index 87fb3dcb7..bb652aca5 100644
--- a/doc/coreutils.texi
+++ b/doc/coreutils.texi
@@ -1240,6 +1240,21 @@ operating system.
To reproduce the results of an earlier invocation of a command, you
can save some random data into a file and then use that file as the
random source in earlier and later invocations of the command.
+@cindex random seed
+Rather than depending on a file, one can generate a reproducible
+arbitrary amount of pseudo-random data given a seed value, using
+for example:
+
+@example
+get_seeded_random()
+@{
+ seed="$1"
+ openssl enc -aes-256-ctr -pass pass:"$seed" -nosalt \
+ </dev/zero 2>/dev/null
+@}
+
+shuf -i1-100 --random-source=<(get_seeded_random 42)
+@end example
@node Target directory
@section Target directory