计算项目中的代码行数:Count the Lines of Code (LOC)

很多时候打开一个大的项目工程时,我们会想知道这个项目有多少行代码。

Visual Studio 自带这个功能,在分析->窗口->代码度量值结果,但是这个功能比较耗时,因为同时分析了代码的耦合程度,继承深度等内容。

powershell中可以实现这个功能,参考自:How do you count the lines of code in a Visual Studio solution? - Stack Overflow

运行命令:

PS D:\ClickHouse>  (gci -include *.c,*.h,*.cpp -recurse | select-string .).Count
2913590

Linux系统我找到了另外一个回答:bash - How to count all the lines of code in a directory recursively? - Stack Overflow

-> # ( find ./ -name '*.cpp' -print0 | xargs -0 cat ) | wc -l
2646250

你可能感兴趣的:(c++,linux,java,python,杂类,windows)