summaryrefslogtreecommitdiff
path: root/randomize.awk
diff options
context:
space:
mode:
authorAndrew Jones <ajones@sgi.com>2005-12-02 05:03:41 +0000
committerAndrew Jones <ajones@sgi.com>2005-12-02 05:03:41 +0000
commit9fdbc7d1e3925251f4c6ce2b95e17a07a9edb269 (patch)
tree4b625c4bd349041fad8e63eff6da21152d448351 /randomize.awk
parent7a8eec9ca89ac5e3df55c12cc04612a81ab775b1 (diff)
Added randomize test option to ./check
Merge of master-melb:xfs-cmds:24664a by kenmcd. Added comment about the randomize '-r' option.
Diffstat (limited to 'randomize.awk')
-rw-r--r--randomize.awk23
1 files changed, 23 insertions, 0 deletions
diff --git a/randomize.awk b/randomize.awk
new file mode 100644
index 00000000..88f86da2
--- /dev/null
+++ b/randomize.awk
@@ -0,0 +1,23 @@
+# Copyright (c) 2005 Silicon Graphics, Inc. All Rights Reserved.
+
+# randomize stdin.
+
+function randomize(array, N) {
+ for(i = 0; i < N; i++) {
+ j = int(rand()*N)
+ if ( i != j) {
+ tmp = array[i]
+ array[i] = array[j]
+ array[j] = tmp
+ }
+ }
+return
+}
+
+{
+ srand()
+ for (i = 0; i < NF; i++ ) array[i] = $(i+1)
+ randomize(array, NF)
+ for (i = 0; i < NF; i++) printf("%s ", array[i])
+}
+