如何递归计算目录中的所有代码行?

跟風遠走 提交于 2020-08-14 22:49:59

问题:

We've got a PHP application and want to count all the lines of code under a specific directory and its subdirectories. 我们有一个PHP应用程序,并希望计算特定目录及其子目录下的所有代码行。 We don't need to ignore comments, as we're just trying to get a rough idea. 我们不需要忽略评论,因为我们只是想弄清楚。

wc -l *.php 

That command works great within a given directory, but ignores subdirectories. 该命令在给定目录中运行良好,但忽略子目录。 I was thinking this might work, but it is returning 74, which is definitely not the case... 我当时认为这可行,但它正在返回74,绝对不是这样......

find . -name '*.php' | wc -l

What's the correct syntax to feed in all the files? 提供所有文件的正确语法是什么?


解决方案:

参考一: https://stackoom.com/question/5hPw/如何递归计算目录中的所有代码行
参考二: https://oldbug.net/q/5hPw/How-to-count-all-the-lines-of-code-in-a-directory-recursively
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!