T
T
tac2012-04-03 22:23:47
Programming
tac, 2012-04-03 22:23:47

How to count the number of lines in multiple text files?

Maybe someone knows, maybe there is some kind of tool that counts the number of lines in several text files? I would like to estimate the size of the C ++ project in lines, it is desirable that empty lines would not be taken into account.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Stanislav, 2012-04-03
@tac

If you want completely with blackjack and the croupier, then there is CCCC - C and C ++ Code Counter

A
AxisPod, 2012-04-04
@AxisPod

Hmm, the size in lines, I also controlled this before, but when my big project exceeded 10 thousand lines, I somehow stopped monitoring this, something b / kb / mb says more.

I
Ivan Komarov, 2012-04-04
@FreeTibet

counting 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/*");
      next;
    }		
    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";

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question