Hi, I'd like to count lines in a file that consists of several blocks, say 3, each with a different number of lines. Each block is separated by a blank line. Is there a one line solution? So far here is what I have:
awk '(NR>4) && NF!=0 {++count} END {print count}' filename > outfile
This obviously counts all non-blank lines (and gets rid of a 4-line header). I now have to include a for loop and after each run it should print the number of lines.
So if I have 100 non-blank lines, and the first block contains 20 lines, the second 50 and the third 30 lines, the ideal output would be 20 50 30
All my effort so far had syntax errors.
Thanks for your help Tom