SHUF(1) General Commands Manual Fully-rendered PDF

shufshuffle lines

shuf [-rz] [-n limit] [-o out-file] [--random-source=rand-file] [file]…
shuf -e [-rz] [-n limit] [-o out-file] [--random-source=rand-file] [line]…
shuf -i from-to [-rz] [-n limit] [-o out-file] [--random-source=rand-file]

Shuffles all lines, then writes up to limit of them to the standard output stream (or out-file, if specified). With -r, writes random lines until limit (for-ever default).

By default, lines originate from files (or standard input stream if "-", the default).
With -e, lines are the non-option arguments.
With -i, lines are all integers in [from, to].

, --echo
Use arguments as lines.
, --input-range=from-to
Use [from, to] as lines.
, --repeat
Continuously randomly sample lines instead of writing a single unique permutation.
, --zero-terminated
Separate input and output lines with a NUL instead of newline.
, --head-count=limit
Write up to limit lines.
, --output=out-file
Write to out-file instead of the standard output stream.
=rand-file
Use randomness from rand-file as the seed. Defaults to an equivalent of /dev/urandom.

if a file couldn't be opened, read, or written.

Originates from the GNU system, also present in FreeBSD. Multiple files are an extension.

March 3, 2024 voreutils 5a9f9f29