Here is a solution for counting lines of code using command line utilities:
$ find . -name '*.rb'|xargs cat|sed '/^\s*#/d;/^\s*$/d'|wc -l
This version specifies Ruby files, and the regex passed to sed
excludes comments in files.
Adapt, test and compare with known files to see how it is working with a particular language.