Count lines of code in a Drupal project

Here's a command that was used on a project I worked on that shows the number of lines of custom code and total lines of code in a project:

Custom code

( find -E ./hooks ./scripts ./tests ./docroot/sites/all/drush ./docroot/sites/all/modules/custom ./docroot/sites/all/themes/custom -regex '.*\.(sah|html|php|inc|module|info|js|scss|sh|css|rb)' -print0 | xargs -0 cat ) | wc -l
* note: you may have to update the theme directory in the code above.

All code

( find -E . -regex '.*\.(sah|html|php|inc|module|info|js|scss|sh|css|rb)' -print0 | xargs -0 cat ) | wc -l

Article Type

General