使用CLOC (Count Line of Code)读取代码行数

jopen 9年前

使用 CLOC (Count Line of Code)


前提条件:1. 预装有perl

                  2. 下载CLOC. http://cloc.sourceforge.net/

解压安装包,得到cloc-version.pl

打开命令行,定位到解压文件的文件夹,然后敲入命令

perl cloc-version.pl YourProject.tar.gz

输出例子:

         594 text files.             126 unique files.                                                        14 files ignored.                http://cloc.sourceforge.net v 1.62  T=14.82 s (7.6 files/s, 925.6 lines/s)        -------------------------------------------------------------------------------        Language                     files          blank        comment           code        -------------------------------------------------------------------------------        Swift                           67           2780           1119           6843        Objective C                      7            265            192           1308        JSON                            27              0              0            697        HTML                             1             11              0            233        C/C++ Header                    10             53             96            125        -------------------------------------------------------------------------------        SUM:                           112           3109           1407           9206        -------------------------------------------------------------------------------  

CLOC支持的文件格式:
ABAP                       (abap)  ActionScript               (as)  Ada                        (ada, adb, ads, pad)  ADSO/IDSM                  (adso)  AMPLE                      (ample, dofile, startup)  Ant                        (build.xml)  Apex Trigger               (trigger)  Arduino Sketch             (ino, pde)  ASP                        (asa, asp)  ASP.Net                    (asax, ascx, asmx, aspx, config, master, sitemap, webinfo)  Assembly                   (asm, S, s)  AutoHotkey                 (ahk)  awk                        (awk)  Bourne Again Shell         (bash)  Bourne Shell               (sh)  C                          (c, ec, pgc)  C Shell                    (csh, tcsh)  C#                         (cs)  C++                        (C, c++, cc, cpp, cxx, pcc)  C/C++ Header               (H, h, hh, hpp)  CCS                        (ccs)  Clojure                    (clj)  ClojureScript              (cljs)  CMake                      (cmake, CMakeLists.txt)  COBOL                      (CBL, cbl, cob, COB)  CoffeeScript               (coffee)  ColdFusion                 (cfm)  ColdFusion CFScript        (cfc)  CSS                        (css)  CUDA                       (cu)  Cython                     (pyx)  D                          (d)  DAL                        (da)  Dart                       (dart)  DOS Batch                  (bat, BAT, btm, BTM, cmd, CMD)  DTD                        (dtd)  ECPP                       (ecpp)  Erlang                     (erl, hrl)  Expect                     (exp)  F#                         (fs, fsi)  Focus                      (focexec)  Fortran 77                 (F, f, F77, f77, pfo)  Fortran 90                 (F90, f90)  Fortran 95                 (F95, f95)  Go                         (go)  Grails                     (gsp)  Groovy                     (gant, groovy)  Haml                       (haml)  Handlebars                 (handlebars, hbs)  Harbour                    (hb)  Haskell                    (hs, lhs)  HLSL                       (cg, cginc, shader)  HTML                       (htm, html)  IDL                        (idl, pro)  InstallShield              (ism)  Java                       (java)  Javascript                 (js)  JavaServer Faces           (jsf, xhtml)  JCL                        (jcl)  JSON                       (json)  JSP                        (jsp, jspf)  Kermit                     (ksc)  Korn Shell                 (ksh)  Kotlin                     (kt)  LESS                       (less)  lex                        (l)  Lisp                       (el, jl, lisp, lsp, sc)  Lisp/OpenCL                (cl)  LiveLink OScript           (oscript)  Lua                        (lua)  m4                         (ac, m4)  make                       (am, gnumakefile, Gnumakefile, Makefile, makefile)  MATLAB                     (m)  Maven                      (pom, pom.xml)  Modula3                    (i3, ig, m3, mg)  MSBuild script             (csproj, vbproj, vcproj, wdproj, wixproj)  MUMPS                      (mps, m)  Mustache                   (mustache)  MXML                       (mxml)  NAnt script                (build)  NASTRAN DMAP               (dmap)  Objective C                (m)  Objective C++              (mm)  OCaml                      (ml, mli, mll, mly)  Oracle Forms               (fmt)  Oracle Reports             (rex)  Pascal                     (dpr, p, pas)  Pascal/Puppet              (pp)  Patran Command Language    (pcl, ses)  Perl                       (perl, PL, pl, plh, plx, pm)  PHP                        (php, php3, php4, php5)  PHP/Pascal                 (inc)  Pig Latin                  (pig)  PL/I                       (pl1)  PowerShell                 (ps1)  Python                     (py)  QML                        (qml)  R                          (R)  Racket                     (rkt, rktl, sch, scm, scrbl, ss)  Razor                      (cshtml)  Rexx                       (rexx)  RobotFramework             (tsv)  Ruby                       (rake, rb)  Ruby HTML                  (rhtml)  Rust                       (rs)  SASS                       (sass, scss)  Scala                      (scala)  sed                        (sed)  SKILL                      (il)  SKILL++                    (ils)  Smarty                     (smarty, tpl)  Softbridge Basic           (sbl, SBL)  SQL                        (psql, sql, SQL)  SQL Data                   (data.sql)  SQL Stored Procedure       (spc.sql, spoc.sql, sproc.sql, udf.sql)  Swift                      (swift)  Tcl/Tk                     (itk, tcl, tk)  Teamcenter met             (met)  Teamcenter mth             (mth)  TypeScript                 (ts)  Unity-Prefab               (mat, prefab)  Vala                       (vala)  Vala Header                (vapi)  Velocity Template Language (vm)  Verilog-SystemVerilog      (sv, svh, v)  VHDL                       (vhd, VHD, VHDL, vhdl)  vim script                 (vim)  Visual Basic               (bas, cls, ctl, dsr, frm, vb, VB, vba, VBA, vbs, VBS)  Visualforce Component      (component)  Visualforce Page           (page)  Windows Message File       (mc)  Windows Module Definition  (def)  Windows Resource File      (rc, rc2)  WiX include                (wxi)  WiX source                 (wxs)  WiX string localization    (wxl)  XAML                       (xaml)  xBase                      (prg)  xBase Header               (ch)  XML                        (XML, xml)  XQuery                     (xq, xquery)  XSD                        (xsd, XSD)  XSLT                       (xsl, XSL, xslt, XSLT)  yacc                       (y)  YAML                       (yaml, yml)
来自:http://blog.csdn.net/tounaobun/article/details/42680307