In alt.os.linux, Aaron Gray wrote:
> Hi,
>
> I have asked this question before but cannot find the thread on Google
> Groups.
>
> Basicaly I want a line of shell code that counts the number of non blank
> lines of code in a file, directory or directory tree.
First off, define what you mean by "non blank lines of code".
Some questions to consider:
/What/ code? (shell script code? java? c++? c? perl? awk? TCL? each
language has it's own concept of what a "line of code" consists of)
Do compound statements count as one line or multiple lines? (Consider
what the C " { something(); something_else(); result=third_thing(); } "
means; is this one, three, four, or five lines of code?
How do you distinguish a "line of code" from other, extraneous lines?
(How do you handle comment lines, for instance?)
How do you want to accomodate "included" files (i.e. source files that
one /or more/ other sources "#include")? Do you count lines once in each
of these files, or do you count them for each time the source file is
included into another source file?
Once you've answered these questions, post your responses, and we'll have a
better understanding of what it is you want to count. From that, we'll be
able to properly provide suggestions on how to count your "lines of code".
> Many thanks in advance,
>
> Aaron
--
Lew Pitcher
Master Codewright & JOAT-in-training | Registered Linux User #112576
http://pitcher.digitalfreehold.ca/ | GPG public key available by request
---------- Slackware - Because I know what I'm doing. ------