PDA

View Full Version : Counting Source Lines?



Davros
08-12-2004, 09:35 PM
Anyone know where I can get a simple source line number counter from? I just want to count non-blank lines in a C++ project. Something with a windows GUI is preferable.

I used to use a thing called C Metrics, but it seems to have vanished from the face of the Earth.

Thanks

jverkoey
08-12-2004, 10:00 PM
C-Metrics! (http://www.TheJeffFiles.com/temp/cmetrics.zip)

huzzah!

-just realized that it's doubly zipped/rarred for some reason...hope that's no big problem for anyone

Get winrar if you don't have it already! (which you should...) (http://www.rarlab.com)

laserlight
08-12-2004, 10:32 PM
Interesting, 7-zip doesnt have rar compression capability, and using zip compression gives a 871 KB filesize. Same for gzip on a tar archive. bzip2 only gives 841 KB as improvement.
7-zip itself gives a 691 KB archive.

Either way I cant reduce the filesize enough to attach it to my post though :mad:

Davros
08-13-2004, 12:27 AM
Thanks!

I don't seem to be able to write anything under 38,000 lines. :)


Found a nice completely free compression utility which did the job:

http://www.izsoft.dir.bg/izarc.htm

linuxdude
08-13-2004, 06:54 AM
why don't you try searching. We have done this before here (http://cboard.cprogramming.com/showthread.php?t=54203&highlight=grep)

the answer you probably want is by Perspective
grep -n .\* in-file > out-file

glUser3f
08-13-2004, 09:18 AM
That command adds line numbers to a file, to count lines in one file:

$ wc -l filename

To count lines in the source tree:

$ grep "" -R source_dir | wc -l

To count non-blank lines:

$ grep -v "^$" -R source_dir | wc -l

If you run Windows, you can get grep.exe by installing Cygwin, it's a free download, just google for the name.

Perspective
08-13-2004, 12:46 PM
or just change -n to -c, no need to pipe to wc ;)

grep -c .\* in-file