Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm trying to figure out how many lines of code I have for files that end in *.pp

 find . -name *.pp -type f  | wc -l
  39

I know that I have 39 files, how can I figure out how many lines of code those 39 files contain?

share|improve this question

2 Answers 2

The following will do the job

find . -name *.pp -type f -exec wc -l {} \;
share|improve this answer

Try this version:

$ find . -iname "*.pp" -type f  -exec wc -l {} +

Here's an example using .cpp files:

$ find . -iname "*.cpp" -type f -exec wc -l {} +
  229 ./jruby-launcher-1.0.7-java/utilsfuncswin.cpp
  269 ./jruby-launcher-1.0.7-java/utilsfuncs.cpp
   84 ./jruby-launcher-1.0.7-java/jrubyexe.cpp
   85 ./jruby-launcher-1.0.7-java/unixlauncher.cpp
  250 ./jruby-launcher-1.0.7-java/platformlauncher.cpp
  593 ./jruby-launcher-1.0.7-java/argparser.cpp
  452 ./jruby-launcher-1.0.7-java/jvmlauncher.cpp
   77 ./jruby-launcher-1.0.7-java/jruby.cpp
 2039 total

I believe if you have more files than will fit on a single command line call to wc that it will give you a total per each call, but this can be modified to do a total of totals if needed.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.