# /* vim: set filetype=awk : */ -*- awk -*- BEGIN { CONVFMT = "%.20g" TestSets = 10; TrainFile = "train.arff"; TestFile = "test.arff" Seed = 1 } NR==1 { srand(Seed); printf "">TrainFile; printf "">TestFile; next } { Data[rand()]=$0 } END { for (I in Data) { Out = (TestSets >= 0) ? TestFile : TrainFile; TestSets-- print Data[I] >> Out } }