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.

Comments imported from the old site.
Way off topic...but

The people who actually keep things rolling in our society very seldom get notice or thanks.  So on this Thanksgiving Day......Thanks ct, you're doing a great job of keeping all the dkos chatter running smoothly.

second that n/t
Somewhere in cyberspace, the ghost of de Chardin is smiling.
Why thank you.

I've been pretty busy with Thanksgiving stuff this weekend, but I still try and keep everything I can to keep the site up and running properly.

good one!

I confirm it works (returns a number) for python.   Probably should modify it do avoid """ """ blocks. Fast.

I love one liners.

ls -clt  | head

I typed that often enough that I finally aliased it as "lately"

ls clt | sort k 5rn

"big"

 
comments powered by Disqus