Re: counting code lines
| From: | James McLean | Date: | Thu, 14 Jun 2007 22:23:52 +0000 |
| Subject: | Re: counting code lines | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-257033@lists.php.net to get a copy of this message | ||
On 6/15/07, Toni Torello <toni.torello@gmail.com> wrote:
hi guys, just supposing... which is the right way to to count the number of code lines in a php application? do you think that the raw: $ find . -name '*.php' -exec cat {} \; | wc -l can be a good estimate?I recently desired to know a similar estimate of the project I was working on and came up with essentially the same thing, but automated it slightly further to encompass other file types also, this is the (perl) script I came up with for your interest: #!/usr/bin/perl -w my @types = qw(php css xml xhtml html js sql); foreach my $type (@types) { print "Lines in files of type: \t" . $type . ": "; my $command = "find . -name *.$type -type f -exec cat {} + | wc -l"; print
$command;
}
Not perfect but it's not bad. Keep in mind it wont see what is a
comment and what isnt for example..
Cheers