如何计算源代码的行数
正如标题所说,我如何使用 bash 命令计算源代码文件夹中的总行数
As the title says how i can calculate the total number of lines in a source code folder using bash commands
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
使用
sloccount
Use
sloccount
你可以只使用
You can just use
使用 cloc。它支持大约 80 种语言。
Use cloc. It supports about 80 languages.
你可以尝试这样的事情:
You could try something like:
我的建议是
find
命令(如 Barti 的答案)来查找所有文件sed
或其他 删除所有注释SLOC 是一种非常非常误导性的软件衡量方式。比尔·盖茨说,这就像通过重量来评估飞机的质量,这可能是他说过的唯一有帮助的话。
My suggestions would be
find
command as in Barti's answer to locate all the filessed
or something to strip out all the commentsSLOC is a very, very misleading way to measure software. Bill Gates said it was like estimating the quality of an aircraft by weight, and it may be the only helpful thing he ever said.
这也会计算空行,但这很容易。转到您想要检查并执行的特定目录
This will count empty lines as well, but it's easy. Go to the specific directory you wanna check and do
已经得到了回答,只是提供了另一种使用
awk
的方法,您肯定会拥有。猫 *.ext | awk 'BEGIN{i=0;} {i++;} END{print "Lines ", i}'
我也建议这样做,因为它可以很容易地编辑,为您想要的行添加模式(例如注释)不想数。
Already been answered, just giving another way using
awk
which you'll definitely have.cat *.ext | awk 'BEGIN{i=0;} {i++;} END{print "Lines ", i}'
I only also suggest this because it can be easily edited to add patterns (such as comments) for lines that you don't want to count.