If you are interested in knowing the total number of actual lines of code a project has, try cloc. It also shows the number of blank lines and comments. However, that’s just the beginning. cloc has many other additional capabilities which make it a very useful tool for developers.
cloc is written in perl and has minimal library dependencies.
Features
- Support 100+ programming languages
- Available in many distros
- Easy to use
- Remove comments from source code
- Work with compressed archives
- Summarize differences between versions
- Create custom language definitions
- Combine reports t show differences by projects
- Write results in SQL and query results
Installation
cloc is available in default repos of many distros. To install cloc on Ubuntu, run:
$ sudo apt-get install cloc
You can also get the latest version from the project page (linked below).
cloc is available for Windows users as an executable too.
Usage
cloc has many options. To learn about them, check cloc help:
$ cloc --help
The simplest usage is to summarize a project:
$ cloc ~/DEVEL/google-cli/ 5 text files. 4 unique files. 4 files ignored. https://github.com/AlDanial/cloc v 1.65 T=0.02 s (82.6 files/s, 21430.5 lines/s) ------------------------------------------------------------------------------- Language files blank comment code ------------------------------------------------------------------------------- Python 1 67 46 374 make 1 5 1 26 ------------------------------------------------------------------------------- SUM: 2 72 47 400 -------------------------------------------------------------------------------
You can also run cloc on a single file.
Webpage: cloc