-
-
Notifications
You must be signed in to change notification settings - Fork 2
Linux shuf Guide
Mattscreative edited this page Dec 5, 2025
·
2 revisions
Complete beginner-friendly guide to shuf on Linux, covering Arch Linux, CachyOS, and other distributions including random shuffling, random selection, and randomization.
Basic usage:
# Shuffle lines
shuf file.txt
# Randomly shuffles linesNumber range:
# Random numbers
shuf -i 1-10
# -i = input range
# Output: random order of 1-10Shuffle file:
# Shuffle file lines
shuf file.txt
# Randomly reorders linesShuffle input:
# Shuffle input
echo -e "line1\nline2\nline3" | shuf
# Shuffles input linesRandom selection:
# Select random lines
shuf -n 5 file.txt
# -n = number (selects 5 random lines)Single line:
# One random line
shuf -n 1 file.txt
# Selects one random lineNumber range:
# From range
shuf -i 1-100
# Shuffles numbers 1-100File input:
# From file
shuf file.txt
# Shuffles lines from fileCheck installation:
# shuf is part of coreutils
# Usually pre-installed
# Check shuf
which shufThis guide covered shuf usage, random shuffling, and random selection for Arch Linux, CachyOS, and other distributions.
- sort Guide - Sorting data
- Bash Scripting Guide - Scripting basics
-
shuf Documentation:
man shuf
This guide covers Arch Linux, CachyOS, and other Linux distributions. For distribution-specific details, refer to your distribution's documentation.