Empowering founders to build the impossible.

Counting lines of code

With Ohloh reporting Drupal core to have roughly 25k lines of code, I was curious to determine how many lines of code were in some of my projects (useful to estimate costs). Finding this out wasn’t nearly as easy as I thought and after the past hour+ of Googling, testing, and resting, I found the following command to work the best for counting lines of code in a Drupal project—at least for me on OSX that is. Enjoy!

find . \( -name '*.module'
  -o -name '*.inc'
  -o -name '*.php'  
  -o -name '*.css'
  -o -name '*.js' \) -exec cat -- {} \; | wc -l

Subscribe to Ted Serbinski

Sign up now to get access to the library of members-only issues.
Jamie Larson