代码行数统计工具cloc,它不但能统计代码行数,还能自动过滤掉代码中的注释,使用起来也很方便,强力推荐。
安装很方便,Ubuntu上直接udo apt-get install cloc就可以了
下面用mysql来做个例子吧,首先进入mysql的源代码文件夹:
qch@qch ~/aproject $ cd mysql-5.6.19/
qch@qch ~/aproject/mysql-5.6.19 $ cloc .
defined(%hash) is deprecated at /usr/bin/cloc line 1277.
(Maybe you should just omit the defined()?)
13804 text files.
13319 unique files.
9686 files ignored.
http://cloc.sourceforge.net v 1.53 T=17.0 s (241.0 files/s, 143571.1 lines/s)
--------------------------------------------------------------------------------
Language files blank comment code
--------------------------------------------------------------------------------
C++ 1153 187301 209441 937741
C 519 36218 40159 457187
C/C++ Header 1389 51302 114475 206003
Java 612 13120 19048 54595
Perl 142 9515 6892 30931
Bourne Shell 142 5293 5848 28855
XML 47 965 1242 7847
SQL 23 764 822 5791
Python 4 346 271 1264
Teamcenter def 21 20 135 1032
Pascal 8 0 1403 969
yacc 2 152 64 810
HTML 5 40 53 524
lex 3 219 102 524
D 9 59 -9 494
Javascript 1 33 62 131
make 3 39 26 108
m4 1 7 27 75
DOS Batch 8 36 78 69
awk 1 2 15 54
Bourne Again Shell 1 8 16 28
YAML 1 0 0 16
SKILL 1 8 15 16
Visual Basic 1 0 0 12
--------------------------------------------------------------------------------
SUM: 4097 305447 400185 1735076
--------------------------------------------------------------------------------
搞定。