简单的脚本来算NLOC? [英] Simple script to count NLOC?
本文介绍了简单的脚本来算NLOC?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你知道一个简单的脚本来算NLOCs(code的内托线)。该脚本应该算C $ C $行C。它不应该算空行或只用括号。但它不需要过于精确任
Do you know a simple script to count NLOCs (netto lines of code). The script should count lines of C Code. It should not count empty lines or lines with just braces. But it doesn't need to be overly exact either.
推荐答案
我会做,使用 AWK &安培; CPP (preprocessor)及厕所。 AWK删除所有括号和空白,在preprocessor删除所有的意见和厕所计数行:
I would do that using awk & cpp (preprocessor) & wc . awk removes all braces and blanks, the preprocessor removes all comments and wc counts the lines:
find . -name \*.cpp -o -name \*.h | xargs -n1 cpp -fpreprocessed -P |
awk '!/^[{[:space:]}]*$/' | wc -l
如果你想有意见包括:
find . -name \*.cpp -o -name \*.h | xargs awk '!/^[{[:space:]}]*$/' | wc -l
这篇关于简单的脚本来算NLOC?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文