diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2013-12-06 09:55:17 -0800 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2013-12-06 09:55:55 -0800 |
commit | e1b753b3e3a3506746f5615cc1f6b5b22f564ccf (patch) | |
tree | f4e31a0a98f8e9dcd1b1b3b2f45f5a78e5b02af0 /doc | |
parent | 34582a1aedae0d7002b76a64a14dc3143198ced0 (diff) | |
download | coreutils-e1b753b3e3a3506746f5615cc1f6b5b22f564ccf.tar.xz |
shuf: --repeat, not --repetitions; default --head-count is infinity
Original problem reported by Philipp Thomas in
<http://bugs.gnu.org/16061>.
* NEWS: shuf --repeat, not shuf --repetitions.
* doc/coreutils.texi (shuf invocation):
* src/shuf.c (usage, long_opts, main):
* tests/misc/shuf.sh:
Likewise. Also, the default head-count is infinity.
Diffstat (limited to 'doc')
-rw-r--r-- | doc/coreutils.texi | 37 |
1 files changed, 13 insertions, 24 deletions
diff --git a/doc/coreutils.texi b/doc/coreutils.texi index 74d502552..ed311a14a 100644 --- a/doc/coreutils.texi +++ b/doc/coreutils.texi @@ -4948,14 +4948,16 @@ Use @var{file} as a source of random data used to determine which permutation to generate. @xref{Random sources}. @item -r -@itemx --repetitions +@itemx --repeat @opindex -r -@opindex --repetitions -@cindex allowing repetitions in output values -Changes the default behaviour of @command{shuf}, allowing repetition in -output values (in which case, @option{--head-count} can be larger -than the number of input values). If @option{--head-count} is not -specified, output a single random value. +@opindex --repeat +@cindex repeat output values +Repeat output values, that is, select with replacement. With this +option the output is not a permutation of the input; instead, each +output line is randomly chosen from all the inputs. This option is +typically combined with @option{--head-count}; if +@option{--head-count} is not given, @command{shuf} repeats +indefinitely. @zeroTerminatedOption @@ -5010,37 +5012,24 @@ and the command @samp{shuf -i 1-4} might output: @end example @noindent -These examples all have four input lines, so @command{shuf} might +The above examples all have four input lines, so @command{shuf} might produce any of the twenty-four possible permutations of the input. In general, if there are @var{n} input lines, there are @var{n}! (i.e., @var{n} factorial, or @var{n} * (@var{n} - 1) * @dots{} * 1) possible output permutations. @noindent -To output 50 random numbers between 0 and 9, use: +To output 50 random numbers each in the range 0 through 9, use: @example -shuf --repetitions --input-range 0-9 --head-count 50 -@end example - -@noindent -or (using short options): - -@example -shuf -r -i0-9 -n50 +shuf -r -n 50 -i 0-9 @end example @noindent To simulate 100 coin flips, use: @example -shuf -r -n100 -e Head Tail -@end example - -@noindent -or -@example -printf '%s\n' Head Tail | shuf -r -n100 +shuf -r -n 100 -e Head Tail @end example @exitstatus |