diff options
| author | Katze Miau <miaukatzemiau@priveasy.de> | 2011-12-03 12:18:12 (GMT) | 
|---|---|---|
| committer | Katze Miau <miaukatzemiau@priveasy.de> | 2011-12-03 12:18:12 (GMT) | 
| commit | 522bfb1a8e9bbe1238dc2fe7991ff42de38b1697 (patch) | |
| tree | cdb9eb1d96bb0354ed626c291f2ff65ce915a1b3 /files/common/sbin | |
| parent | 9a4a525faf37508a6b9d487b40ffdc25bced1a9d (diff) | |
add primitive shuf
Diffstat (limited to 'files/common/sbin')
| -rwxr-xr-x | files/common/sbin/shuf | 16 | 
1 files changed, 16 insertions, 0 deletions
diff --git a/files/common/sbin/shuf b/files/common/sbin/shuf new file mode 100755 index 0000000..8d82d4d --- /dev/null +++ b/files/common/sbin/shuf @@ -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 +    } +}  | 
