-3

Say I have a project folder containing a number of header and source files for c++; How would I count the total number of lines of all of these?

Anon
  • 215
  • 2
  • 12

1 Answers1

1

The wc command with option -l prints the line count of each file and a total if multiple files are given as input.

Say I have two files foo.cpp and bar.h with 10 lines each, then wc -l gives this result:

$ wc -l *.cpp *.h
10 foo.cpp
10 bar.h
20 total

If you only need the total value, you could cat the files and pipe the result to wc -l:

$ cat *.cpp *.h | wc -l
20
Freddy
  • 25,172
  • 1
  • 21
  • 60