Count Lines of Code

Posted by Tejus Parikh on January 13, 2008

Occasionally, I find myself wonder just how many lines of code I’ve written. Most of the time, I just run some combination of find and wc. But that situation is far from ideal. It doesn’t account for comments, blank-lines, etc. Sometimes, I write a half-assed script to strip out some of the comments in the language I’m most interested in. Again, that has a some drawbacks, especially when I’m working on a multi-language project.

I did some Googling and came across CLOC. It’s just a simple Perl script that ran without any extra fiddling on my Leopard machine. When you run it, it gives you a breakdown of all the code in a directory or in a specific set of files, regardless of language. If your curious about the amount of code that you’ve written, or just how much cleaner things got after the last refactor, give this neat tool a shot.

Related Posts:

Tejus Parikh

Tejus is an software developer, now working at large companies. Find out when I write new posts on twitter, via RSS or subscribe to the newsletter: