Get the App
SLTechnology News&Howtos  ›  Development  › 

What is the use of the shuf command in Linux

Shulou Source: shulou.com Published: 2022-06-01 17:59:15 09月19日 Update

This article mainly introduces the use of the shuf command in Linux, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.

The common Linux command shuf is used to output input lines to standard output in random order.

Shuf produces random permutations.

Summary shuf [OPTION]... [FILE] shuf-e [OPTION]. [ARG]... Shuf-I LO-HI [OPTION]... The main purpose is to randomly arrange and output the input.

Read standard input when there is no file or when the file is -.

The option-e,-- echo treats each ARG as an input line. -I,-- input-range=LO-HI takes the numeric range from LO (lowest) to HI (highest) as the input line. -n,-- head-count=COUNT outputs only the previous COUNT lines. -o,-- output=FILE writes the results to a file instead of standard output. -- random-source=FILE uses the content in FILE as a random data source. -r,-- repeat output lines can be repeated. -z,-- zero-terminated line Terminator is NUL (null character) instead of the default newline character. -- help displays help information and exits. -- version displays version information and exits. Parameter FILE (optional): any number of files to be processed.

ARG (optional): a string as an input line, which can be any number.

A return value of 0 indicates success, while a non-zero value indicates failure.

Example # simulated coin toss Get the first 10 results: [user2@pc ~] $head-r-n 10-e "heads"-e "tails" heads # Sports Lottery Super Lotto: [user2@pc ~] $shuf-I 1-35-n 5 | sort-n & & shuf-I 1-12-n 2 | sort-n 4 17 20 29 31 6 11 Note this command is a command in the GNU coreutils package For more detailed help, please see man-s 1 shuf,info coreutils' shuf invocation'.

Thank you for reading this article carefully. I hope the article "what is the use of shuf commands in Linux" shared by the editor will be helpful to you. At the same time, I also hope that you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Tags: Heads input output commands tails files articles information standards help content quantity more result lowest highest success between value sports lottery Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux Redmi macOS Xiaomi Microsoft