diff options
Diffstat (limited to 'shuf.sh')
-rw-r--r-- | shuf.sh | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -0,0 +1,18 @@ +exec awk "$(tail -n +2 $0)" "$@" + +{ + lines[NR] = $0; + printed[NR] = 0; +} + +END { + nprinted = 0; + while (nprinted < NR) { + line = int(rand() * NR); + if (!printed[line]) { + print lines[line]; + printed[line] = 1; + nprinted++; + } + } +} |