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