Lines of Code

A quick way to find the lines of code under a subdirectory:

find | grep “.cs$” | awk ‘//{print “\””$0″\””;}’| xargs wc

It recursively finds all the files under a directory, passes through a grep filter (which you would have to update based on your preferred language of development), awks it to enclose it with quotes and then passes to wc using xargs. Neat!

My current project now has about 31k lines of code, out of which about 9.5k is mine. Messy!

[Thanks to Robin for help with the commands]

About kpowerinfinity
I *♥* technology, business, conversations, experiences, books, music, theater, coffee and people. I am an entrepreneur in the city of Bangalore - my company, Capillary, provides customer engagement programs and marketing services to retailers around the world.

One Response to Lines of Code

  1. Arindam says:

    KK Pwnd

    find . -name “*.cs” |xargs grep -v ‘^\ *//’ |wc -l
    1. find is more intuitive and has a lot more options :)
    2. using the reverse parameter on grep, I avoid awk, which is far far slower .. while xargs passes the file name onto it.

    on 2nd thought, if we need to remove /* .. */ block patterns, we might need to sed it thru grep ………..
    but not the “awkward” way, definitely

%d bloggers like this: