shuf shuffles its input by outputting a random permutation of its input lines. Each output permutation is equally likely. Synopses:
shuf [option]... [file]
shuf -e [option]... [arg]...
shuf -i lo-hi [option]...
shuf has three modes of operation that affect where it obtains its input lines. By default, it reads lines from standard input. The following options change the operation mode:
shuf's other options can affect its behavior in all operation modes:
shuf -o F <F and cat F | shuf -o F.
For example:
shuf <<EOF
A man,
a plan,
a canal:
Panama!
EOF
might produce the output
Panama!
A man,
a canal:
a plan,
Similarly, the command:
shuf -e clubs hearts diamonds spades
might output:
clubs
diamonds
spades
hearts
and the command ‘shuf -i 1-4’ might output:
4
2
1
3
These examples all have four input lines, so shuf might produce any of the twenty-four possible permutations of the input. In general, if there are n input lines, there are n! (i.e., n factorial, or n * (n - 1) * ... * 1) possible output permutations.
An exit status of zero indicates success, and a nonzero value indicates failure.