Scroll to navigation

shuf(1) General Commands Manual shuf(1)

NAME

shuf - 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.

SYNOPSIS

shuf [-e|--echo] [-i|--input-range] [-n|--head-count] [-o|--output] [--random-seed] [--random-source] [-r|--repeat] [-z|--zero-terminated] [-h|--help] [-V|--version] [file-or-args]

DESCRIPTION

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

treat each ARG as an input line
treat each number LO through HI as an input line
output at most COUNT lines
write result to FILE instead of standard output
shuf-help-random-seed
get random bytes from FILE
output lines can be repeated
line delimiter is NUL, not newline
Print help
Print version
[file-or-args]

VERSION

v(uutils coreutils) 0.7.0

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 <https://tldr.sh> under the CC BY 4.0 License. Please note that, as uutils is a work in progress, some examples might fail.

shuf (uutils coreutils) 0.7.0