summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKatze Miau <miaukatzemiau@priveasy.de>2011-12-03 12:18:12 (GMT)
committerKatze Miau <miaukatzemiau@priveasy.de>2011-12-03 12:18:12 (GMT)
commit522bfb1a8e9bbe1238dc2fe7991ff42de38b1697 (patch)
treecdb9eb1d96bb0354ed626c291f2ff65ce915a1b3
parent9a4a525faf37508a6b9d487b40ffdc25bced1a9d (diff)
add primitive shuf
-rwxr-xr-xfiles/common/sbin/shuf16
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
+ }
+}
contact: Jan Huwald // Impressum