Shuf

Table of Contents

shuf

Generate random permutations.

Randomize the order of lines in a file and output the result:

shuf filename
seq 10 | shuf

Only output the first 5 entries of the result:

shuf -n 5 filename
seq 10 | shuf -n 5

Write the output to another file:

NOTE: the output file is the one immediately after the -o flag!

shuf test.txt -o test2.txt

Generate 3 random numbers in the range 1-10 (inclusive):

NOTE: The “repeat” flag means output lines can appear more than once.

shuf -n 3 -i 1-10 --repeat

Footer

Copyright © 2020-2021 Derek Taylor (DistroTube)

This page is licensed under a Creative Commons Attribution-NoDerivatives 4.0 International License (CC-BY-ND 4.0).

The source code for distro.tube can be found on GitLab. User-submitted contributions to the site are welcome, as long as the contributor agrees to license their submission with the CC-BY-ND 4.0 license.

Author: dt

Created: 2022-02-20 Sun 10:16