@millgates - I think your second answer could be on to something, however, if the last file read, fort.500, has let us say 10 lines in it, then FNR will equal only 10 but there may be 100's
of other lines, as per the data example, which would need to be averaged.
@OP - my question back to you would be, is the average always of all files which means if a file has less numbers than another it will assume zero for other entries or should the
average only be calculated based on the number of files that have the same corresponding line numbers?
$ cat fort.1
$ cat fort.2
So in this example, if we look at the second part of my question, you would only average the first 6 lines by 2 as line wise they both have this many, whereas the last
3 lines in file 1 would be divided by 1 as they only appear in 1 file?