Uploaded August 2025 | Updated November 2026, 1 week ago
The 'shuf' command is used to generate random permutations. In other words, it "shuffles" lines of text or series of numbers.
- Shuffle the order of lines in a file and output the result:
shuf path/to/file
- Only output the a certain "number" of entries in the result:
shuf -n 10 path/to/file
- Write the "output" to another file:
shuf path/to/input_file -o path/to/output_file
- Generate a random ordering of an "input" range 1-10:
shuf -i 1-10
- Generate a random odering of an "input" range 1-100 and out 1 entry:
shuf -i 1-100 -n 1
NOTE Useful in situations where you want to randomize your actions based on percentages.
- "Repeatedly" generate a random ordering of an "input" range of numbers 1-10:
shuf -i 1-10 -r
- Line delimiter is NULL rather than newline:
shuf -i 0-9 -z
REFERENCED:
βΊ gitlab.com/dwt1/vidman
WANT TO SUPPORT THE CHANNEL?
π° Patreon: patreon.com/distrotube
π³ Paypal: youtube.com/redirect?event=channel_banner&redir_token=QUFFLUhqazNocEhiaGFBT1l1MnRHbnlIcHFKbXJWVnpQd3xBQ3Jtc0tsLVZJc19YeFlwZ2JqbXVOa3g0Skw4TVhTV2otNm1tM3A1bUNnamh3S2V6OGQtLTBnSjBxYTlvUXMxeEVIS3o4US10NENHMUQ3STk2a01FOFBhUnZjZFctMEhFUTg1TVctQmFfVUdxZXJ4TDl0azlYNA&q=https%3A%2F%2Fwww.paypal.com%2Fcgi-bin%2Fwebscr%3Fcmd%3D_donations%26business%3Dderek%2540distrotube%252ecom%26lc%3DUS%26item_name%3DDistroTube%26no_note%3D0%26currency_code%3DUSD%26bn%3DPP%252dDonationsBF%253abtn_donateCC_LG%252egif%253aNonHostedGuest
ποΈ Amazon: amzn.to/2RotFFi
π Teespring: teespring.com/stores/distrotube
DT ON THE WEB:
πΈοΈ Website: http://distro.tube
π GitLab: gitlab.com/dwt1
π¨οΈ Mastodon: fosstodon.org/@distrotube
π« Reddit: reddit.com/r/DistroTube
π½οΈ Odysee: odysee.com/@DistroTube:2
FREE AND OPEN SOURCE SOFTWARE THAT I LIKE:
π Brave Browser - brave.com
π½οΈ Open Broadcaster Software: obsproject.com
π¬ Kdenlive: kdenlive.org
π¨ GIMP: gimp.org
π» VirtualBox: virtualbox.org
ποΈ Doom Emacs: github.com/hlissner/doom-emacs
Your support is very much appreciated. Thanks, guys!
The 'shuf' command is used to generate random permutations. In other words, it "shuffles" lines of text or series of numbers.
- Shuffle the order of lines in a file and output the result:
shuf path/to/file
- Only output the a certain "number" of entries in the result:
shuf -n 10 path/to/file
- Write the "output" to another file:
shuf path/to/input_file -o path/to/output_file
- Generate a random ordering of an "input" range 1-10:
shuf -i 1-10
- Generate a random odering of an "input" range 1-100 and out 1 entry:
shuf -i 1-100 -n 1
NOTE Useful in situations where you want to randomize your actions based on percentages.
- "Repeatedly" generate a random ordering of an "input" range of numbers 1-10:
shuf -i 1-10 -r
- Line delimiter is NULL rather than newline:
shuf -i 0-9 -z
REFERENCED:
βΊ gitlab.com/dwt1/vidman
WANT TO SUPPORT THE CHANNEL?
π° Patreon: patreon.com/distrotube
π³ Paypal: youtube.com/redirect?event=channel_banner&redir_token=QUFFLUhqazNocEhiaGFBT1l1MnRHbnlIcHFKbXJWVnpQd3xBQ3Jtc0tsLVZJc19YeFlwZ2JqbXVOa3g0Skw4TVhTV2otNm1tM3A1bUNnamh3S2V6OGQtLTBnSjBxYTlvUXMxeEVIS3o4US10NENHMUQ3STk2a01FOFBhUnZjZFctMEhFUTg1TVctQmFfVUdxZXJ4TDl0azlYNA&q=https%3A%2F%2Fwww.paypal.com%2Fcgi-bin%2Fwebscr%3Fcmd%3D_donations%26business%3Dderek%2540distrotube%252ecom%26lc%3DUS%26item_name%3DDistroTube%26no_note%3D0%26currency_code%3DUSD%26bn%3DPP%252dDonationsBF%253abtn_donateCC_LG%252egif%253aNonHostedGuest
ποΈ Amazon: amzn.to/2RotFFi
π Teespring: teespring.com/stores/distrotube
DT ON THE WEB:
πΈοΈ Website: http://distro.tube
π GitLab: gitlab.com/dwt1
π¨οΈ Mastodon: fosstodon.org/@distrotube
π« Reddit: reddit.com/r/DistroTube
π½οΈ Odysee: odysee.com/@DistroTube:2
FREE AND OPEN SOURCE SOFTWARE THAT I LIKE:
π Brave Browser - brave.com
π½οΈ Open Broadcaster Software: obsproject.com
π¬ Kdenlive: kdenlive.org
π¨ GIMP: gimp.org
π» VirtualBox: virtualbox.org
ποΈ Doom Emacs: github.com/hlissner/doom-emacs
Your support is very much appreciated. Thanks, guys!









![sed - filter and transform text - Video Man Pages
The sed command is a very powerful shell utility that is used to filter and transform text.
- Replace first instance on each line of old with new using basic regex and print to stdout:
command | sed s/old/new/
- Replace old with new on all lines using basic regex and print to stdout:
sed s/old/new/g path/to/file
- Replace case-insensitive old with new on all lines and print to stdout:
sed s/old/new/gi path/to/file
- Replace old with OLD on all lines using extended regex and print to stdout:
sed -E s/(old)/U1/g path/to/file
command | sed -E s/(old)/U1/g
NOTE U convert to uppercase; 1 tells it to convert the first capture group of the sed command (which is old).
- Replace old with new in-place in a file (writes to the file!):
sed -i s/old/new/g path/to/file
- Replace old with new and first with second in-place in a file (writes to the file!):
sed -i -e s/old/new/g -e s/first/second/g path/to/file
- Print the first 10 lines to stdout (similar to head):
command | sed -n 10p
NOTE The -n flag suppresses the printing of the entire output of the command. Without the -n, it would print the 10 lines and then it would print the entire output from command.
- Print only lines that contain the pattern (similar to grep):
sed -n /pattern/p path/to/file
- Delete pattern and print to stdout:
sed /pattern/d path/to/file
- Delete lines 1-4 of a file and create a back up file with the .bak extension:
sed -i.bak 1,4d path/to/file
- Delete blank lines (with or without spaces/tabs) from a file and print to stdout:
sed /^[[:space:]]*$/d path/to/file
- Insert a new line at the beginning of file, overwriting the file in-place:
sed -i 1iA new first line path/to/file
- Inserting a line before a pattern and print to stdout.
sed /pattern/iThis is a new line path/to/file
- Append a line after a pattern and print to stdout.
sed /pattern/aThis is a new line path/to/file
REFERENCED:
βΊ https://gitlab.com/dwt1/vidman
WANT TO SUPPORT THE CHANNEL?
π° Patreon: https://www.patreon.com/distrotube
π³ Paypal: https://www.paypal.com/donate/?hosted_button_id=MW3ZFGS8Q9JGW
ποΈ Amazon: https://amzn.to/2RotFFi
π Teespring: https://teespring.com/stores/distrotube
DT ON THE WEB:
πΈοΈ Website: http://distro.tube
π GitLab: https://gitlab.com/dwt1
π¨οΈ Mastodon: https://fosstodon.org/@distrotube
π« Reddit: https://www.reddit.com/r/DistroTube/
π½οΈ Odysee: https://odysee.com/@DistroTube:2
FREE AND OPEN SOURCE SOFTWARE THAT I LIKE:
π Brave Browser - https://brave.com/
π½οΈ Open Broadcaster Software: https://obsproject.com/
π¬ Kdenlive: https://kdenlive.org
π¨ GIMP: https://www.gimp.org/
π» VirtualBox: https://www.virtualbox.org/
ποΈ Doom Emacs: https://github.com/hlissner/doom-emacs
Your support is very much appreciated. Thanks, guys! sed - filter and transform text - Video Man Pages](https://i.ytimg.com/vi/D7aDAXWi5SM/mqdefault.jpg)
