Forrest logo
tool overview
On this page you find all important commands for the CLI tool shuf. If the command you are looking for is missing please ask our AI.

shuf

Shuf is a command line tool commonly found in Unix-like operating systems. It is primarily used to generate random permutations of input lines or files. The word "shuf" is an abbreviation for "shuffle", which accurately reflects its purpose. Its main function is to randomly order the lines of a file or the elements of a list. Shuf provides various options to control the output, including specifying the number of output lines and limiting the range of lines to shuffle. Additionally, it allows for exact repetition prevention, ensuring each line is only output once during shuffling. Shuf is useful for various tasks such as creating randomized test data sets, generating random passwords, and selecting random winners from a list. It can accept input from files, standard input, or command line arguments, making it highly flexible. Shuf is often praised for its simplicity, efficiency, and ability to handle large input files with ease.

List of commands for shuf:

  • shuf:tldr:5f813 shuf: Write the output to another file.
    $ shuf ${path-to-input} --output=${path-to-output}
    try on your machine
    explain this command
  • shuf:tldr:60beb shuf: Generate random numbers in range 1-10.
    $ shuf --input-range=${1-10}
    try on your machine
    explain this command
  • shuf:tldr:6821d shuf: Only output the first 5 entries of the result.
    $ shuf --head-count=${5} ${filename}
    try on your machine
    explain this command
  • shuf:tldr:837f4 shuf: Generate 3 random numbers in the range 1-10 (inclusive).
    $ shuf --head-count=${3} --input-range=${1-10} --repeat
    try on your machine
    explain this command
  • shuf:tldr:d42e4 shuf: Randomize the order of lines in a file and output the result.
    $ shuf ${filename}
    try on your machine
    explain this command
tool overview