Text and processing
The shuf command
Randomly shuffles lines, values or a range of numbers. Handy for draws and tests.
Syntax
shuf [-n N] [-e valores | -i 1-10 | archivo]Most useful options
-eShuffles the values you pass-iShuffles a range, e.g. 1-10-nReturns only N resultsCopy-ready examples
$ shuf -i 1-49 -n 6Six random numbers$ shuf -e oro plata bronceShuffle a listYou can try them in the browser terminal: it does not touch your computer.
Typical mistakes
- It can repeat if you give repeated values; for no repetition use a range.
FAQ
Can shuf be used for a fair draw?
Yes: shuf -i 1-100 -n 1 returns a random number.
Learn to actually use it
The basic Linux course takes you from zero to console fluency with 24 self-grading lessons.
Start the free course