BEGIN { FS = ","; getline; out = ""; NR = 0; } { data[NR] = $1 " " $2 "\n" #out = $1 " " $2 "\n" out; } END { for (i=NR; i>0; i--) { n = NR - i + 1; out = out n " " data[i]}; print out; }