Improve script - slow process with big files

To expand on what stomp already said, your script seems to read the input file n+1 times, once to detect the count of reports ( = n) and their respective location in it (one sed and one awk invocation), then using a shell loop to "extract" and analyse the respective single reports, invoking awk 13 times, and sed 4 times per loop (i.e. 130 awk s and 40 sed s for the sample file with 10 reports).

No surprise this will be somewhat lengthy on large files with many reports...