Dickiebird,
yep that is the right spec, I couldn´t get the code typed in bold to work though I´m not really a unix expert.
I was getting the line count using grep of data lines and wc -l, (isn´t there any way of this total being written directly to the end of the last line instead of starting...