聘我网

新概念招聘3.0

如何快速地查看某个项目代码数量级?

vote up0vote downstar

拿到一个大的开源项目,如何快速估算其代码行数?

 

2 个答复

vote up0vote downcheck

看文件数:

[root@nginx-1.0.2]# find . -name "*.[hc]" -print |wc -l
246

看行数:

[root@nginx-1.0.2]# find . -name "*.[hc]" -print |xargs wc -l |tail -n1 
 119212 总计

以上是计算.h.c文件相关的统计数据,根据需要可以作相应修改。

链接
vote up0vote down

findshellglob不支持多字节的语法:{a,b}.

如果后缀是多字节的,需要用正则:

find . -regextype posix-extended -regex '.*\.(c|h|cc)' -print |wc -l

如果要排除目录(有些目录名会带后缀):

find . -regextype posix-extended -type f -regex '.*\.(c|h|cc)' -print |wc -l

更新

其实最简单的还是shellglob:

find . -name '*.c' -o -name '*.h' -o -name '*.cc' | wc -l
链接

您的回答





不是您要找的问题? 浏览其他含有标签 的问题或者 自己问个.