1 .\" SPDX-License-Identifier: BSD-2-Clause
3 .\" Copyright (c) 2022 Alessio Chiapperini
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions
8 .\" 1. Redistributions of source code must retain the above copyright
9 .\" notice, this list of conditions and the following disclaimer.
10 .\" 2. Redistributions in binary form must reproduce the above copyright
11 .\" notice, this list of conditions and the following disclaimer in the
12 .\" documentation and/or other materials provided with the distribution.
14 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 .Nd generate random permutations
55 utility shuffles its input by outputting a random permutation of its input lines.
57 The options are as follows:
58 .Bl -tag -width indent
60 Treat each command-line operand in
64 Cannot be combined with
67 Print usage information and exit
69 act as input came from a file containing the numbers in the interval of unsigned integers
71 one on each line. The range of possible values for
80 output lines are printed on
82 instead of standard output.
84 repeat values. When this option is turned on, the output no longer contains permutations of the input lines,
85 instead each output line is randomly chosen from all the input lines. If
89 prints randomly chosen input lines indefinitely.
94 utility exits 0 on success, and 1 if an error occurs.
96 Output 5 random numbers in the range 0-2:
97 .Dl "shuf -n 5 -r -i 0-2"
99 Flip a coin ten times:
100 .Dl shuf -e -n 10 -r Heads Tails
102 Select five numbers from 10 to 20:
103 .Dl shuf -i 10-20 -n 5
105 Shuffle what is provided on standard input and write the output to
109 .Bl -tag -width indent
110 .It Input lines are limited to BUFSIZ bytes in length.
111 .It Does not implement the -z and --random-source=file flags present in GNU coreutils' Nm
112 .It Uses the rand() function from stdlib.h.
115 .An Alessio Chiapperini Aq Mt alessio.chiapperini@\:nullbuffer.com