One Liners

Handy one liners: counting lines of code

Just a little one liner to count lines of code in your source tree. This assumes you're working with perl - adjust the 'iname' argument as necessary. It also isn't smart enough to skip over pod documentation, but does skip over blank lines and lines that are only comments (but doesn't skip over lines with comments after actual code, or $#array variables). This should work fine with python and ruby, but probably not real well with Java, C, or PL/I.

find . -iname *pm -print | xargs perl -e 'while (<>) { next if /^\s*$|^\s*?#/; print $_; }' | wc -l

Oh, this also assumes you work in a Unixy environment. That one liner won't be too useful in Windows unless you have Cygwin installed. The results it returns won't be entirely accurate (because of the issue with pod documentation), but should give a reasonably close to correct figure.