2014-09-08 13:27:44 +04:00
|
|
|
# shuf
|
|
|
|
|
2016-01-07 18:31:27 +01:00
|
|
|
> Generate random permutations.
|
2021-04-01 17:54:26 +02:00
|
|
|
> More information: <https://www.gnu.org/software/coreutils/shuf>.
|
2014-09-08 13:27:44 +04:00
|
|
|
|
2016-01-07 18:31:27 +01:00
|
|
|
- Randomize the order of lines in a file and output the result:
|
2014-09-08 13:27:44 +04:00
|
|
|
|
|
|
|
`shuf {{filename}}`
|
|
|
|
|
2018-07-29 11:09:06 +05:30
|
|
|
- Only output the first 5 entries of the result:
|
2014-09-08 13:27:44 +04:00
|
|
|
|
2021-05-20 16:07:38 -03:00
|
|
|
`shuf --head-count={{5}} {{filename}}`
|
2014-09-08 13:27:44 +04:00
|
|
|
|
2018-07-29 11:09:06 +05:30
|
|
|
- Write the output to another file:
|
2014-09-08 13:27:44 +04:00
|
|
|
|
2021-05-20 16:07:38 -03:00
|
|
|
`shuf {{filename}} --output={{output_filename}}`
|
2014-09-10 17:58:31 +04:00
|
|
|
|
2021-05-20 11:50:45 -03:00
|
|
|
- Generate 3 random numbers in the range 1-10 (inclusive):
|
2014-09-10 17:58:31 +04:00
|
|
|
|
2021-05-20 16:07:38 -03:00
|
|
|
`shuf --head-count={{3}} --input-range={{1-10}} --repeat`
|