I am looping through a list of files, extracting the final line, and printing out columns 8, 9, and 10. I need to also print to the output the 'event number', which is essentially the total number of records being processes (NR). How do I print the event/record number in the first column, outputting to the output file, such as what I have below?
for i in `ls -d *mcp`; do
tail -1 "$i" | awk '{ printf "%s %s %s\n", $8, $9, $10}' >> ${Pout}${output}
done
echo "Finished Looping through each file."
What I want as the output is:
1 45 60 5
2 30 67 3
3 40 12 4
.
.
.
where the '45 column represents $8, 60 represents $9, and 5 represents $10. the 1,2,3, etc. is what I need to output. I essentially need to print the line number.