Scroll to navigation

countcode(1) General Commands Manual countcode(1)


countcode - counts per known source file type the number of source lines


countcode [-h] [-b] [-c] [-s] [-l] [-p PRINTLEVEL] [-d] [-t] [-v] [directory]


countcode counts per known source file type the number of source lines in the files in the given directory and recursively in its subdirectories. It supports many file types. The type is recognized from the file name extension or the shebang script type. Use -s to see all supported types.

The following line types are counted:

code: pure code lines comment: pure comment lines blank: empty lines or lines containing whitespace only header: the copyright header (leading comment lines) other: all other lines

Unless -b is given, a pure code or comment line has to contain an alphanumeric character; e.g., a single } does not count as code line. It calculates the percentage of code and comment lines in the total number of lines or (if -l is given) in the sum of code and comment lines. Unless -t is given, files in test directories are counted separately. Normal output is written on stdout; verbose on stderr. Files with an unknown type are reported on stderr. Note that -bt should give about the same results as a tool like cloc.

positional arguments:

name of top directory to count source files (default is .)

optional arguments:

-h, --help
show this help message and exit
-b, --basic
count copyright header and lines without an alphanumeric character as code/comment lines
-c, --code
only use source files containing code (e.g. no .parset)
-s, --sum
only calculate and print the sum of all file types
-l, --limitperc
limit to the nr of code and comment lines to determine percentages
first directory level to print (default 0 (=top))
-d, --displaytypes
display the currently recognized file types (full info with -v)
-t, --testinclude
do not count test directories separately
-v, --verbose
print count for each source file


This manual page was written with the help of help2man by Benda Xu <>, for the Debian GNU/Linux system.
2016-03-25 caascore