通常开始接手一个项目时,往往不清楚项目到底有多大,代码量具体有多少行。linux下提供了一个很好的工具cloc来计算项目的代码量。
一、首先需要安装cloc,这里以ubuntu为例。
sudo apt-get install cloc
二、查看cloc的使用方法,使用cloc --help
defined(%hash) is deprecated at /usr/bin/cloc line 1277.
(Maybe you should just omit the defined()?)
Usage: cloc [options] <file(s)/dir(s)> | <report files>
Count physical lines of source code in the given files (may be
archives such as compressed tarballs or zip files) and/or
recursively below the given directories.
Input Options
--extract-with=<cmd> This option is only needed if cloc is unable
to figure out how to extract the contents of
the input file(s) by itself.
Use <cmd> to extract binary archive files (e.g.:
.tar.gz, .zip, .Z). Use the literal '>FILE<' as
a stand-in for the actual file(s) to be
extracted. For example, to count lines of code
in the input files
gcc-4.2.tar.gz perl-5.8.8.tar.gz
on Unix use
--extract-with='gzip -dc >FILE< | tar xf -'
or, if you have GNU tar,
--extract-with='tar zxf >FILE<'
and on Windows use:
--extract-with="\"c:\Program Files\WinZip\WinZip32.exe\" -e -o >FILE< ."
(if WinZip is installed there).
--list-file=<file> Take the list of file and/or directory names to
process from <file> which has one file/directory
name per line. See also --exclude-list-file.
--unicode Check binary files to see if they contain Unicode
expanded ASCII text. This causes performance to
drop noticably.
Processing Options
--by-file Report results for every source file encountered.
--by-file-by-lang Report results for every source file encountered
in addition t