1

I am trying to get line of code statistics for my xcode code. For that i executed the following command in Terminal to get all possible kinds of codes.

find . "(" -name "*.m" -or -name "*.mm" -or -name "*.cpp" -or -name "*.h" -or -name "*.xml" ")" -print0 | xargs -0 wc -l | sort

It gives me the number of code lines including comments also. Can anyone tell me how to get line of code statistics without comments.

JasonMArcher
  • 14,195
  • 22
  • 56
  • 52
Gani414
  • 93
  • 2
  • 12

1 Answers1

1

Consider using cloc, which would give you a nice output like:

7892 text files.
4289 unique files.                                          
9574 files ignored.

http://cloc.sourceforge.net v 1.56  T=58.0 s (43.9 files/s, 7442.5 lines/s)
--------------------------------------------------------------------------------
Language                      files          blank        comment           code
--------------------------------------------------------------------------------
Objective C                     872          44323          20568         198133
HTML                             34           1032              8          76432
C/C++ Header                    908          16427          35415          19872
D                               684              0              0           8299
C                                 8            889            534           4040
MUMPS                             3            618              0           2781
Bourne Shell                     18            175            327            622
Ruby                              2             87             15            380
XML                              10              0              0            264
CSS                               1             41              8            219
Python                            1              9             16             41
Objective C++                     2             15             12             26
Bourne Again Shell                1              4              4             10
YAML                              1              0              0              9
make                              1              2              0              7
--------------------------------------------------------------------------------
SUM:                           2546          63622          56907         311135
--------------------------------------------------------------------------------
Wain
  • 118,658
  • 15
  • 128
  • 151
  • Just copy the file into a folder that's on your PATH (so to somewhere like `/usr/local/bin/cloc`). Then `cd` to your project and run it as `cloc .`. All dependencies should be installed by default on your machine. – Wain Jul 10 '13 at 10:40