PDA

View Full Version : Need script or Program to count lines of source code



Olnex
March 10th, 2009, 01:11 PM
Hello, I need a script or a program that can count how many lines are there in a directory contains source code as well as other directories(contain code as well), there are .java files in these directories, the script or program should count number of lines with/without comments(starts with // or surrounded by /**/)

Thanks a lot!!!

simeon87
March 10th, 2009, 01:31 PM
Try cloc: http://cloc.sourceforge.net/

mike_g
March 10th, 2009, 05:24 PM
Or you could just call wc (http://www.computerhope.com/unix/uwc.htm) from the shell, but Idont think you can exclude comments with it.

bobbocanfly
March 10th, 2009, 08:13 PM
There is a program called sloccount that does this. It (recursively) searches through your source tree and gives you a report of all the languages used and how many lines of code written in each language.

It is in Universe, so you can just run

sudo apt-get install sloccount