# Example call: # gawk -f randomize.awk -v Seed=$Seed -v TestSets=$TestSets -v TrainFile=$TrainFile -v TestFile=$TestFile $Filename BEGIN { CONVFMT = "%.20g" } NR==1 { srand(Seed); } # Seed the random number generator. { Data[rand()]=$0 } END { count = 0 for (I in Data) { if (count < TestSets ) { print Data[I] >> TestFile } else { print Data[I] >> TrainFile } count++ } }