SHUF(1)

πŸ’… SHUF(1) β€” General Commands Manual πŸŽ€

okay bestie, gather round, because shuf is literally the moment. it's the shuf command from the General Commands Manual, and it's about to rearrange your whole life (or at least your stdin).


✨ NAME ✨

shuf β€” shuffle the input by outputting a random permutation of input lines 🌈

and like, every single output permutation is equally likely, no cap, it's not playing favourites. with no FILE, or when FILE is -, it reads standard input. πŸ’–


πŸ¦‹ SYNOPSIS πŸ¦‹

shuf [OPTION]... [FILE]
shuf -e [OPTION]... [ARG]...
shuf -i LO-HI [OPTION]...

three whole vibes, pick your fighter. πŸ‘‘


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

that's it, that's the whole personality β€” it takes your lines, it mixes them up, and every possible order has the exact same chance of showing up. it's giving fairness icon. ✨

not me feeding it a file and getting a completely different order every time β€” because that's literally the point, bestie 😭

πŸŽ€ OPTIONS πŸŽ€

  • -e, --echo β€” treat each ARG as an input line πŸ’œ (so instead of a file, you just hand it words and it goes feral)
  • -i, --input-range <LO-HI> β€” treat each number LO through HI as an input line πŸ”’
  • -n, --head-count <COUNT> β€” output at most COUNT lines, like, we're not doing the whole thing today 🫢
  • -o, --output <FILE> β€” write the result to FILE instead of standard output πŸ’Ύ
  • --random-seed <STRING> β€” seed with STRING for reproducible output 🌱 (yes bestie, same seed = same shuffle, science)
  • --random-source <FILE> β€” get random bytes from FILE 🎲
  • -r, --repeat β€” output lines can be repeated πŸ”
  • -z, --zero-terminated β€” line delimiter is NUL, not newline 🚫 (the NUL one, not the newline one, iykyk)
  • -h, --help β€” Print help πŸ†˜
  • -V, --version β€” Print version πŸ“Œ
  • [file-or-args] β€” yeah, it's listed right there at the bottom of the options, iconic placement honestly πŸ’…

⭐ VERSION ⭐

v(uutils coreutils) 0.12.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.

🫢 real talk: as uutils is a work in progress, a couple of these examples might just not go how you want. it's not you, it's the work in progress era. πŸ’€

and that's the whole page bestie, slay. this lovely little doc is served up by the General Commands Manual crew, rocking v(uutils coreutils) 0.12.0, and it was stamped with the date 2026-09-25. go shuffle something, you ate. πŸ‘‘βœ¨πŸ’–

πŸ“¦ where this page comes from