TOOL » LINUX » PACKAGE

Shuf

Usage

Generate random permutations.

With no FILE, stdin is used.

shell
shuf OPTIONS FILE
OptionDescription
-n --head-countOutput at most COUNT lines.
-z --zero-terminatedLine delimiter is NUL, not newline.

Example

Shuffle file names in current directory:

shell
printf '%s\n' * | shuf

Select random file from directory:

shell
printf '%s\0' * | shuf -zn 1