Lines of Code

26 Jun

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 these ads

One Response to “Lines of Code”

  1. Arindam June 27, 2007 at 7:34 am #

    MUHAHUAAHAUAA !!
    KK Pwnd

    ———————————————–
    find . -name “*.cs” |xargs grep -v ‘^\ *//’ |wc -l
    ———————————————–
    reasons:
    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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 434 other followers

%d bloggers like this: