Counting sloc with bash

1st of August 2008

Nothing particularly exciting, this is just one of those tricks that need written down because getting the syntax right can be fustrating.

cat filelist | grep -v "^\s*$"  | grep -v -e '^ *$' -e '^ *%' | wc -l

Where filelist the path to the files you want to inspect, for example, all the files in src/ with extension .erl will be

cat src/*.erl | grep -v "^\s*$"  | grep -v -e '^ *$' -e '^ *%' | wc -l

This command will not include blank lines and lines beginning with % (a comment in erlang), sloccount and cloc.py look far more extensive, but neither currently support erlang (sloccount will in the next ubuntu)

Comments


There has been no comments


Post a Comment


Name :
Url :
Comment :
html is enabled, you may post links / images and basic formatting, styling is permitted.
The colour of grass is :
Simple check against spamming robots