# Example call: # gawk -f separate.awk -v Target=$Target -v TrainFile=$TrainFile -v TestFile=$TestFile $Filename { if (NR==Target) { print $0 >> TestFile } else { print $0 >> TrainFile } }