if I want to count the lines of code, the trivial thing is
cat *.c *.h | wc -l
But what if I have several subdirectories?
if I want to count the lines of code, the trivial thing is
But what if I have several subdirectories? |
||||
|
|||||||||||||
|
You should probably use SLOCCount or cloc for this, they're designed specifically for counting lines of source code in a project, regardless of directory structure etc.; either
or
will produce a report on all the source code starting from the current directory. If you want to use
(Thanks to SnakeDoc for the cloc suggestion!) |
|||||||||||||||||||||
|
You can use
|
|||||||||
|
As the
Alternately, in
Other shells traverse recursively by default (e.g. |
|||
|
easy command:
|
|||||
|
Sample using
|
|||||||||||||
|
|
|||||||||||||||||
|
cat
?wc -l *.c *.h
does the same thing. – Thomas Padron-McCarthy yesterdaywc -l *.c *.h | tail -n 1
to get similar output. – Gilles 20 hours ago**
, so you could have usedwc -l **/*.{h,c}
or something similar. Note that in Bash, at least, this option (calledglobstar
) is off by default. But also note that in this particular case,cloc
orSLOCCount
is a much better option. (Also,ack
may be preferable tofind
for easily finding/listing source files.) – Kyle Strand 19 hours ago