Counting lines of code

◷ 1 minute to read   ⁓   Next post →

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

Read this next:

SimpleFeed 1.0 ships! →