Shuf

Table of Contents

Home DTOS Knowledge Base Community Contribute Support DT’s Work

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

Author: Derek Taylor

Created: 2021-08-27 Fri 15:34