diff options
| author | Jan Huwald <jh@sotun.de> | 2012-06-19 09:14:41 (GMT) |
|---|---|---|
| committer | Jan Huwald <jh@sotun.de> | 2012-06-19 09:14:41 (GMT) |
| commit | 743581225719056a79a378f04ebb44cea1bc3b8e (patch) | |
| tree | 00cf65adbf911ac8bd8b0ea6329fa27b018e62de | |
| -rwxr-xr-x | shuf | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -0,0 +1,16 @@ +#!/usr/bin/awk -f +BEGIN{ + srand() # seed by time + srand(seed+srand()) # allow additional external seed +} +{ lines[++d]=$0 } +END{ + while (d > 0) { + if (e==d) {break} + r = int(1 + rand() * d) + print lines[r] + lines[r] = lines[d] + delete lines[d] + --d + } +} |
