开发者

Number of lines in all files in a directory [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.

Want to improve this question? Update the question so it focuses on one problem only by editing this post.

Closed 7 years ago.

Improve this question

I have a folder with many source code files.

I would like to f开发者_如何转开发ind the total number of lines of source code in all files in the directory.

Is there any simple way to do this?

These are cobol files, I do not have a dev tool that will open them, so I cannot just run code metrics.


Assuming you are using *nix, Mac OS X or even cygwin under Windows:

$ wc -l *

If you want to include subdirectories then you can do it like this:

$ find . -type f -print0 | xargs -0 wc -l

If you just want the grand total (i.e. skip all the individual line counts for each file) then pipe to tail, e.g.

$ find . -type f -print0 | xargs -0 wc -l | tail -1


use SLOCCOUNT a well-known and free source line of code counting.

It supports COBOL and use COCOMO model to estimate effort and schedule.


A really quick-n-dirty way to get a close, but not exact, count would be:

tar -c /path/to/source/code | wc -l

This isn't perfectly exact, because tar adds some junk at the beginning, and between each file. If you have any non-ascii files in your source path, that will throw things off, too.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜