.\" Automatically generated by Pod::Man 2.25 (Pod::Simple 3.16) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .ie \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . nr % 0 . rr F .\} .el \{\ . de IX .. .\} .\" ======================================================================== .\" .IX Title "cloc 1" .TH cloc 1 "2013-08-20" "cloc" "User Commands" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" cloc \- Count, and compute differences of, lines of source code and comments. .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& cloc [options] ... .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" Count, or compute differences of, 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. It is written entirely in Perl, using only modules from the standard distribution. .SH "OPTIONS" .IX Header "OPTIONS" .SS "Input Options" .IX Subsection "Input Options" To count standard input, use the special filename \fB\-\fR. .IP "\fB\-\-extract\-with=CMD\fR" 4 .IX Item "--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 \s-1CMD\s0 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: .Sp .Vb 1 \& \-\-extract\-with=\*(Aqgzip \-dc >FILE< | tar xf \- .Ve .Sp or, if you have \s-1GNU\s0 tar: .Sp .Vb 1 \& \-\-extract\-with=\*(Aqtar zxf >FILE<\*(Aq .Ve .Sp and on Windows, use, for example: .Sp .Vb 1 \& \-\-extract\-with="\e"c:\eProgram Files\eWinZip\eWinZip32.exe\e" \-e \-o >FILE< .Ve .IP "\fB\-\-list\-file=FILE\fR" 4 .IX Item "--list-file=FILE" Take the list of file and/or directory names to process from \s-1FILE\s0 which has one file/directory name per line. See also \&\fB\-\-exclude\-list\-file\fR .IP "\fB\-\-unicode\fR" 4 .IX Item "--unicode" Check binary files to see if they contain Unicode expanded \s-1ASCII\s0 text. This causes performance to drop noticably. .SS "Processing Options" .IX Subsection "Processing Options" .IP "\fB\-\-autoconf\fR" 4 .IX Item "--autoconf" Count .in files (as processed by \s-1GNU\s0 autoconf) of recognized languages. .IP "\fB\-\-by\-file\fR" 4 .IX Item "--by-file" Report results for every source file encountered. .IP "\fB\-\-by\-file\-by\-lang\fR" 4 .IX Item "--by-file-by-lang" Report results for every source file encountered in addition to reporting by language. .IP "\fB\-\-diff \s-1SET1\s0 \s-1SET2\s0\fR" 4 .IX Item "--diff SET1 SET2" Compute differences in code and comments between source file(s) of \&\s-1SET1\s0 and \s-1SET2\s0. The inputs may be pairs of files, directories, or archives. Use \fB\-\-diff\-alignment\fR to generate a list showing which file pairs where compared. See also \fB\-\-ignore\-case\fR, \&\fB\-\-ignore\-whitespace\fR. .IP "\fB\-\-diff\-timeout N\fR" 4 .IX Item "--diff-timeout N" Ignore files which take more than N seconds to process. Default is 10 seconds. (Large files with many repeated lines can cause \&\fIAlgorithm::Diff::sdiff()\fR to take hours.) .IP "\fB\-\-follow\-links\fR" 4 .IX Item "--follow-links" [Unix only] Follow symbolic links to directories (sym links to files are always followed). .IP "\fB\-\-force\-lang=LANG[,EXT]\fR" 4 .IX Item "--force-lang=LANG[,EXT]" Process all files that have a \s-1EXT\s0 extension with the counter for language \s-1LANG\s0. For example, to count all .f files with the Fortran 90 counter (which expects files to end with .f90) instead of the default Fortran 77 counter, use: .Sp .Vb 1 \& \-\-force\-lang="Fortran 90",f .Ve .Sp If \s-1EXT\s0 is omitted, every file will be counted with the \s-1LANG\s0 counter. This option can be specified multiple times (but that is only useful when \s-1EXT\s0 is given each time). See also \fB\-\-script\-lang\fR, \&\fB\-\-lang\-no\-ext\fR. .IP "\fB\-\-force\-lang\-def=FILE\fR" 4 .IX Item "--force-lang-def=FILE" Load language processing filters from \s-1FILE\s0, then use these filters instead of the built-in filters. Note: languages which map to the same file extension (for example: MATLAB/Objective C/MUMPS; Pascal/PHP; Lisp/OpenCL) will be ignored as these require additional processing that is not expressed in language definition files. Use \fB\-\-read\-lang\-def\fR to define new language filters without replacing built-in filters (see also \fB\-\-write\-lang\-def\fR). .IP "\fB\-\-ignore\-whitespace\fR" 4 .IX Item "--ignore-whitespace" Ignore horizontal white space when comparing files with \fB\-\-diff\fR. See also \fB\-\-ignore\-case\fR. .IP "\fB\-\-ignore\-case\fR" 4 .IX Item "--ignore-case" Ignore changes in case; consider upper\- and lowercase letters equivalent when comparing files with \fB\-\-diff\fR. See also \fB\-\-ignore\-whitespace\fR. .IP "\fB\-\-lang\-no\-ext=LANG\fR" 4 .IX Item "--lang-no-ext=LANG" Count files without extensions using the \s-1LANG\s0 counter. This option overrides internal logic for files without extensions (where such files are checked against known scripting languages by examining the first line for \f(CW\*(C`#!\*(C'\fR). See also \fB\-\-force\-lang\fR, \fB\-\-script\-lang\fR. .IP "\fB\-\-max\-file\-size=MB\fR" 4 .IX Item "--max-file-size=MB" Skip files larger than \f(CW\*(C`MB\*(C'\fR megabytes when traversing directories. By default, \f(CW\*(C`MB\*(C'\fR=100. cloc's memory requirement is roughly twenty times larger than the largest file so running with files larger than 100 \s-1MB\s0 on a computer with less than 2 \s-1GB\s0 of memory will cause problems. Note: this check does not apply to files explicitly passed as command line arguments. .IP "\fB\-\-read\-binary\-files\fR" 4 .IX Item "--read-binary-files" Process binary files in addition to text files. This is usually a bad idea and should only be attempted with text files that have embedded binary data. .IP "\fB\-\-read\-lang\-def=FILE\fR" 4 .IX Item "--read-lang-def=FILE" Load new language processing filters from \s-1FILE\s0 and merge them with those already known to cloc. If \s-1FILE\s0 defines a language cloc already knows about, cloc's definition will take precedence. Use \&\fB\-\-force\-lang\-def\fR to over-ride cloc's definitions. (see also \fB\-\-write\-lang\-def\fR). .IP "\fB\-\-script\-lang=LANG,S\fR" 4 .IX Item "--script-lang=LANG,S" Process all files that invoke \f(CW\*(C`S\*(C'\fR as a \f(CW\*(C`#!\*(C'\fR scripting language with the counter for language \s-1LANG\s0. For example, files that begin with \&\f(CW\*(C`#!/usr/local/bin/perl5.8.8\*(C'\fR will be counted with the Perl counter by using .Sp .Vb 1 \& \-\-script\-lang=Perl,perl5.8.8 .Ve .Sp The language name is case insensitive but the name of the script language executable, \f(CW\*(C`S\*(C'\fR, must have the right case. This option can be specified multiple times. See also \fB\-\-force\-lang\fR. .IP "\fB\-\-sdir=DIR\fR" 4 .IX Item "--sdir=DIR" Use \s-1DIR\s0 as the scratch directory instead of letting \fIFile::Temp\fR chose the location. Files written to this location are not removed at the end of the run (as they are with \fIFile::Temp\fR). .IP "\fB\-\-skip\-uniqueness\fR" 4 .IX Item "--skip-uniqueness" Skip the file uniqueness check. This will give a performance boost at the expense of counting files with identical contents multiple times (if such duplicates exist). .IP "\fB\-\-stdin\-name=FILE\fR" 4 .IX Item "--stdin-name=FILE" Count lines streamed via \fI\s-1STDIN\s0\fR as if they came from a file named \s-1FILE\s0. .IP "\fB\-\-strip\-comments=EXT\fR" 4 .IX Item "--strip-comments=EXT" For each file processed, write to the current directory a version of the file which has blank lines and comments removed. The name of each stripped file is the original file name with \f(CW\*(C`.EXT\*(C'\fR appended to it. It is written to the current directory unless \fB\-\-original\-dir\fR is on. .IP "\fB\-\-original\-dir\fR" 4 .IX Item "--original-dir" Write the stripped files the same directory as the original files. Only effective in combination with \fB\-\-strip\-comments\fR. .IP "\fB\-\-sum\-reports\fR" 4 .IX Item "--sum-reports" Input arguments are report files previously created with the \&\fB\-\-report\-file\fR option. Makes a cumulative set of results containing the sum of data from the individual report files. .IP "\fB\-\-unix\fR" 4 .IX Item "--unix" Over-ride the operating system detection logic and run in \s-1UNIX\s0 mode. See also \fB\-\-windows\fR, \fB\-\-show\-os\fR. .IP "\fB\-\-windows\fR" 4 .IX Item "--windows" Over-ride the operating system detection logic and run in Microsoft Windows mode. See also \fB\-\-unix\fR, \fB\-\-show\-os\fR. .SS "Filter Options" .IX Subsection "Filter Options" .IP "\fB\-\-exclude\-dir= ...]>" 4 .IX Item "--exclude-dir= ...]>" Exclude the given comma separated directories from being scanned. For example: .Sp .Vb 1 \& \-\-exclude\-dir=.cache,test .Ve .Sp will skip all files that match \f(CW\*(C`/.cache/\*(C'\fR or \f(CW\*(C`/test/\*(C'\fR as part of their path. Directories named \f(CW\*(C`.bzr\*(C'\fR, \f(CW\*(C`.cvs\*(C'\fR, \f(CW\*(C`.hg\*(C'\fR, \f(CW\*(C`.git\*(C'\fR, \&\f(CW\*(C`.hg\*(C'\fR, and \f(CW\*(C`.svn\*(C'\fR are always excluded. .IP "\fB\-\-exclude\-ext=EXT1[,EXT2 ...]\fR" 4 .IX Item "--exclude-ext=EXT1[,EXT2 ...]" Do not count files having the given file name extensions. .IP "\fB\-\-exclude\-lang= ...]>" 4 .IX Item "--exclude-lang= ...]>" Exclude the given comma separated languages from being counted. .IP "\fB\-\-exclude\-list\-file=FILE\fR" 4 .IX Item "--exclude-list-file=FILE" Ignore files whose names appear in \s-1FILE\s0. \s-1FILE\s0 should have one entry per line. Relative path names will be resolved starting from the directory where cloc is invoked. See also \fB\-\-list\-file\fR. .IP "\fB\-\-match\-d=REGEX\fR" 4 .IX Item "--match-d=REGEX" Only count files in directories matching the Perl regex. For example .Sp .Vb 1 \& \-\-match\-d=\*(Aq/(src|include)/\*(Aq .Ve .Sp only counts files in directory paths containing \f(CW\*(C`/src/\*(C'\fR or \f(CW\*(C`/include/\*(C'\fR. .IP "\fB\-\-not\-match\-d=REGEX\fR" 4 .IX Item "--not-match-d=REGEX" Count all files except in directories matching the Perl regex. .IP "\fB\-\-match\-f=REGEX\fR" 4 .IX Item "--match-f=REGEX" Only count files whose basenames match the Perl regex. For example this only counts files at start with Widget or widget: .Sp .Vb 1 \& \-\-match\-f=\*(Aq^[Ww]idget\*(Aq .Ve .IP "\fB\-\-not\-match\-f=REGEX\fR" 4 .IX Item "--not-match-f=REGEX" Count all files except those whose basenames match the Perl regex. .IP "\fB\-\-skip\-archive=REGEX\fR" 4 .IX Item "--skip-archive=REGEX" Ignore files that end with the given Perl regular expression. For example, if given \-\-skip\-archive='(zip|tar(\e.(gz|Z|bz2|xz|7z))?)' the code will skip files that end with .zip, \&.tar, .tar.gz, .tar.Z, .tar.bz2, .tar.xz, and \&.tar.7z. .IP "\fB\-\-skip\-win\-hidden\fR" 4 .IX Item "--skip-win-hidden" On Windows, ignore hidden files. .SS "Debug Options" .IX Subsection "Debug Options" .IP "\fB\-\-categorized=FILE\fR" 4 .IX Item "--categorized=FILE" Save names of categorized files to \s-1FILE\s0. .IP "\fB\-\-counted=FILE\fR" 4 .IX Item "--counted=FILE" Save names of processed source files to \s-1FILE\s0. .IP "\fB\-\-diff\-alignment=FILE\fR" 4 .IX Item "--diff-alignment=FILE" Write to \s-1FILE\s0 a list of files and file pairs showing which files were added, removed, and/or compared during a run with \fB\-\-diff\fR. This switch forces the \fB\-\-diff\fR mode on. .IP "\fB\-\-help\fR" 4 .IX Item "--help" Print this usage information and exit. .IP "\fB\-\-found=FILE\fR" 4 .IX Item "--found=FILE" Save names of every file found to \s-1FILE\s0. .IP "\fB\-\-ignored=FILE\fR" 4 .IX Item "--ignored=FILE" Save names of ignored files and the reason they were ignored to \s-1FILE\s0. .IP "\fB\-\-print\-filter\-stages\fR" 4 .IX Item "--print-filter-stages" Print to \fI\s-1STDOUT\s0\fR processed source code before and after each filter is applied. .IP "\fB\-\-show\-ext[=EXT]\fR" 4 .IX Item "--show-ext[=EXT]" Print information about all known (or just the given) file extensions and exit. .IP "\fB\-\-show\-lang[=LANG]\fR" 4 .IX Item "--show-lang[=LANG]" Print information about all known (or just the given) languages and exit. .IP "\fB\-\-show\-os\fR" 4 .IX Item "--show-os" Print the value of the operating system mode and exit. See also \&\fB\-\-unix\fR, \fB\-\-windows\fR. .IP "\fB\-v[=" 4 .IX Item "-v[=" Turn on verbose with optional numeric value. .IP "\fB\-\-version\fR" 4 .IX Item "--version" Print the version of this program and exit. .IP "\fB\-\-write\-lang\-def=FILE\fR" 4 .IX Item "--write-lang-def=FILE" Writes to \s-1FILE\s0 the language processing filters then exits. Useful as a first step to creating custom language definitions. See also \&\fB\-\-force\-lang\-def\fR, \fB\-\-read\-lang\-def\fR. .SS "Output Options" .IX Subsection "Output Options" .IP "\fB\-\-3\fR" 4 .IX Item "--3" Print third-generation language output. (This option can cause report summation to fail if some reports were produced with this option while others were produced without it.) .IP "\fB\-\-progress\-rate=N\fR" 4 .IX Item "--progress-rate=N" Show progress update after every N files are processed (default N=100). Set N to 0 to suppress progress output; useful when redirecting output to \fI\s-1STDOUT\s0\fR. .IP "\fB\-\-quiet\fR" 4 .IX Item "--quiet" Suppress all information messages except for the final report. .IP "\fB\-\-report\-file=FILE\fR" 4 .IX Item "--report-file=FILE" Write the results to \s-1FILE\s0 instead of standard output. .IP "\fB\-\-out=FILE\fR" 4 .IX Item "--out=FILE" Synonym for \fB\-\-report\-file=FILE\fR. .IP "\fB\-\-csv\fR" 4 .IX Item "--csv" Write the results as comma separated values. .IP "\fB\-\-csv\-delimiter=C\fR" 4 .IX Item "--csv-delimiter=C" Use the character C as the delimiter for comma separated files instead of ,. This switch forces \fB\-\-csv\fR to be on. .IP "\fB\-\-sql=FILE\fR" 4 .IX Item "--sql=FILE" Write results as \s-1SQL\s0 \s-1CREATE\s0 and \s-1INSERT\s0 statements which can be read by a database program such as SQLite. If \s-1FILE\s0 is \fB\-\fR, output is sent to \&\fI\s-1STDOUT\s0\fR. .IP "\fB\-\-sql\-project=NAME\fR" 4 .IX Item "--sql-project=NAME" Use as the project identifier for the current run. Only valid with the \fB\-\-sql\fR option. .IP "\fB\-\-sql\-append\fR" 4 .IX Item "--sql-append" Append \s-1SQL\s0 insert statements to the file specified by \fB\-\-sql\fR and do not generate table creation option. .IP "\fB\-\-sum\-one\fR" 4 .IX Item "--sum-one" For plain text reports, show the \s-1SUM:\s0 output line even if only one input file is processed. .IP "\fB\-\-xml\fR" 4 .IX Item "--xml" Write the results in \s-1XML\s0. .IP "\fB\-\-xsl[=FILE]\fR" 4 .IX Item "--xsl[=FILE]" Reference \s-1FILE\s0 as an \s-1XSL\s0 stylesheet within the \s-1XML\s0 output. If \s-1FILE\s0 is not given, writes a default stylesheet, cloc.xsl. This switch forces \&\fB\-\-xml\fR to be on. .IP "\fB\-\-yaml\fR" 4 .IX Item "--yaml" Write the results in \s-1YAML\s0. .SH "EXAMPLES" .IX Header "EXAMPLES" Count the lines of code in the Perl 5.10.0 compressed tar file on a UNIX-like operating system: .PP .Vb 1 \& cloc perl\-5.10.0.tar.gz .Ve .PP Count the changes in files, code, and comments between Python releases 2.6.6 and 2.7: .PP .Vb 1 \& cloc \-\-diff Python\-2.6.6.tar.bz Python\-2.7.tar.bz2 .Ve .PP To see how cloc aligns files for comparison between two code bases, use the \fB\-\-diff\-alignment=FILE\fR option. Here the alignment information is written to \f(CW\*(C`align.txt\*(C'\fR: .PP .Vb 1 \& cloc \-\-diff\-aligment=align.txt gcc\-4.4.0.tar.bz2 gcc\-4.5.0.tar.bz2 .Ve .PP Print the recognized languages .PP .Vb 1 \& cloc \-\-show\-lang .Ve .PP Remove comments from \f(CW\*(C`foo.c\*(C'\fR and save the result in \f(CW\*(C`foo.c.nc\*(C'\fR .PP .Vb 1 \& cloc \-\-strip\-comments=nc foo.c .Ve .PP Additional examples can be found at . .SH "ENVIRONMENT" .IX Header "ENVIRONMENT" None. .SH "FILES" .IX Header "FILES" None. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIsloccount\fR\|(1) .SH "AUTHORS" .IX Header "AUTHORS" The cloc program was written by Al Danial and is Copyright (C) 2006\-2013 Northrop Grumman Corporation. .PP The manual page was originally written by Jari Aalto . .PP Both the code and documentation is released under the \s-1GNU\s0 \s-1GPL\s0 version 2 or (at your option) any later version. For more information about license, visit .