shufコマンドで繰り返しを許容してシャッフルする方法
shufコマンドで繰り返しを許容してシャッフルするには-rオプションを指定します。
オプションの説明
-n, --head-count=COUNT output at most COUNT lines -r, --repeat output lines can be repeated
-rオプションを指定した場合(-nオプションを指定しないと延々と出力される)
$ cat test.txt apple banana orange lemon peach $ shuf -r -n 3 test.txt lemon lemon banana $ shuf -r -n 10 test.txt peach lemon banana apple peach apple orange orange apple peach
-rオプションを指定しない場合
$ shuf test.txt banana apple orange lemon peach $ shuf test.txt peach orange lemon banana apple