How to count lines in multiple text files?

Who knows, maybe there's some tool counts the number of lines in several text files? I would like to estimate the size of a C++ project in rows, it is desirable that empty strings are not recognized.
October 8th 19 at 00:53
3 answers
October 8th 19 at 00:55
If you want a very blackjack and the dealer, that is, CCCC — C and C++ Code Counter
There are still cloc.sourceforge.netgenerally dozens of such tools. If a project is open it is possible to to add, it'll count. - Akeem.Cremin68 commented on October 8th 19 at 00:58
Well or stupidly find. -type f | xargs wc. - denis9 commented on October 8th 19 at 01:01
October 8th 19 at 00:57
Hmm, the size in lines, I also used this control, but when my big project has exceeded 10 thousand rows, I somehow lost track of it, something b/kb/mb about more says.
October 8th 19 at 00:59
count lines in files in the current directory (including subdirectories) in perl:
sub countdir {
 my $dir = shift @_;
 my @files = < $dir >;
 my $count = 0;
 for my $file (@files) {
 if (-d $file) {
 $count += countdir("$file/*");
 open my $fd, '<', $file or die "cannot open file $file\n";
 my @lines = <$fd>;
 close $fd;
 map { $count++ if ($_ !~ /^\s*$/) } @lines;
 return $count;

print countdir('./*') . "\n";

Find more questions by tags Source codeProgrammingWeb Development