A simple program to read from the current folder all source file listings that
end with .prn and count the total number of Cobol code lines.

It will ignore any secondary listing within each one that starts with 000001 as
it assumes that any such are in fact c object packs as GC lists those as well -
yes a bug in gc listing routine - must get around to reporting it.

As well as blank lines at least where the first six character only have spaces
as against a numeric value in the range - 000000 to 999999 etc as anything else
is ignored.

Note that listings containing nested program will work as the number increases
by one for the next nested program / module.

I have tested it against my ACAS accounting sources and manually checking one sub
systems folder with only 10 -12 sources and the .prn files and then running
cntlines in the same folder - was the same.

Note that cntlines must be run from the top folder holding your sources where
you have previously run cobc -x|-x progname.cbl -T progname.prn on all your
source code files that you want counted.

It only looks for files ending with .prn and ONLY lower case.

As ACAS has scripts for compiling the system by sub system which in my case is
irs, general, purchase, sales and stock it works as advertised. By running it
in just one lower level folder it will do the same as it issues command  -

find . -name '*.prn' | sort > cnt.tmp

Then reads the file cnt.tmp counting and searching for non number cc1-6 etc.

It starts with a display of the program name and version and finishes with a
total count on line 3.

During processing and when starting to reading each source file it can display
a progress marker but as at least for my ACAS application it is very quick,
around 1 second (but I run using a M.2 SSD so on a slow HDD will may be longer)
I have commented this code out.

If needed, you can always remove the comment markers (*>) and recompile.
Having moved to the folder containing the source, to compile is just :
cobc -x cntlines.cbl then cp cntlines to your active bin/executable folder.

Easy, but as to why, I needed a total size of the applications cobol source code
in lines of Cobol code to include in my documentation for ACAS (which is on the
sourceforge website under ACAS - sourceforge.net/p/acas.

Note as is, it will not work under Windows, only *nix platforms as it uses
a *nix s/ript and that would need to be changed for a windows version of the
find bash command.

Vincent Coen
Created 23 September 2025.
Updated 25 September 2025.
Updated 30 May       2026 - Typos.
