Files
apfstests/randomize.awk
T

29 lines
438 B
Awk
Raw Normal View History

# SPDX-License-Identifier: GPL-2.0
2005-12-02 05:03:41 +00:00
# Copyright (c) 2005 Silicon Graphics, Inc. All Rights Reserved.
2009-06-05 15:41:14 -05:00
#
2005-12-02 05:03:41 +00:00
# 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
}
2019-03-19 17:44:42 -07:00
BEGIN {
srand(seed)
}
2005-12-02 05:03:41 +00:00
{
2019-03-19 17:44:42 -07:00
array[NR - 1] = $0
}
END {
randomize(array, NR)
for (i = 0; i < NR; i++) printf("%s ", array[i])
2005-12-02 05:03:41 +00:00
}