shuf
shuf [OPTION]... [FILE]
shuf -e [OPTION]... [ARG]...
shuf -i LO-HI [OPTION]...
Shuffle the input by outputting a random permutation of input lines. Each output permutation is equally likely. With no FILE, or when FILE is -, read standard input.
Options
--echo,-e-
treat each ARG as an input line
--input-range=<LO-HI>,-i <LO-HI>-
treat each number LO through HI as an input line
--head-count=<COUNT>,-n <COUNT>-
output at most COUNT lines
--output=<FILE>,-o <FILE>-
write result to FILE instead of standard output
--random-seed=<STRING>-
seed with STRING for reproducible output
--random-source=<FILE>-
get random bytes from FILE
--repeat,-r-
output lines can be repeated
--zero-terminated,-z-
line delimiter is NUL, not newline
Examples
Randomize the order of lines in a file and output the result:
shuf {{path/to/file}}
Only output the first 5 entries of the result:
shuf {{[-n|--head-count]}} 5 {{path/to/file}}
Write the output to another file:
shuf {{path/to/input_file}} {{[-o|--output]}} {{path/to/output_file}}
Generate 3 random numbers in the range 1-10 (inclusive, numbers can repeat):
shuf {{[-n|--head-count]}} 3 {{[-i|--input-range]}} 1-10 {{[-r|--repeat]}}
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.