cloc: count lines of code

hacker_compIf 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

Comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s