iOS 项目代码行数统计

1. 打开终端;

2. 通过cd命令到达我们的工程文件,这里注意如果要避免统计引用的第三方库的代码量,我们就要进一步进到我们自己写的代码文件中去,一般是一个与工程文件同名的文件;

3. 统计代码行数:

如果想列出每个文件的行数,输入命令:

find . -name "*.m" -or -name "*.h" -or -name "*.xib" -or -name "*.c" |xargs wc -l    

如果想直接列出总代码行数,输入命令:

find . -name "*.m" -or -name "*.h" -or -name "*.xib" -or -name "*.c" |xargs grep -v "^$"|wc -l    

这样就可以直接得出数量了,而且非常快,是不是很方便~

这个统计过程会去掉空行,但注释是会计算在内的。



注:

Getting error “xargs unterminated quote” when tried to print the number of lines in terminal

Does one of your filenames have a quote in it? Try something like this:

find . "(" -name "*.m" -or -name "*.h" ")" -print0 | xargs -0 wc -l

The -print0 argument tells find to use the NULL character to terminate each name that it prints out. The -0 argument tells xargs that its input tokens are NULL-terminated. This avoids issues with characters that otherwise would be treated as special, like quotes.

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

友情链接更多精彩内容