CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Main CFD Forum (https://www.cfd-online.com/Forums/main/)
-   -   Counting number of lines in multi-file large code (https://www.cfd-online.com/Forums/main/8441-counting-number-lines-multi-file-large-code.html)

Abhijit Tilak December 12, 2004 13:45

Counting number of lines in multi-file large code
 
Hello all,

Is anybody aware of any free utility for calculating number of lines in a multi-file (40-50 files language C, platform RedHat 9.0) code. Ideally I am looking for something that may work like this:

<utility_name> input >> *.c output << < total number of lines in *.c>>

I checked out programmers_heaven.com. There are some utilities like this for MS Windows, but they operate on single file. I thought about using cat or grep, but it does'nt seem like a smart idea.

Here's how this question came about: I recently had an interview with a FEA s/w development company. The interviewer asked me how many lines is your code ? I told the interviewer that I never kept track of that!

Thanks Abhijit


Hrvoje Jasak December 12, 2004 15:59

Re: Counting number of lines in multi-file large c
 
You're using Unix, right? The command you want is wc -l So:

cat *.c | wc -l

for all .c files in a directory; or more complex:

find . -type f -name "*.[ch]pp" -exec cat {} \; | wc -l

to find all files .hpp and .cpp files in the currect directory tree and count them. For more info, read man pages :)

Abhijit Tilak December 12, 2004 16:10

Re: Counting number of lines in multi-file large c
 
Hello Dr. Jasak,

wow! you nailed it. Thanks for your answer.

Abhijit

zxaar December 12, 2004 17:33

Re: Counting number of lines in multi-file large c
 
and if u are in windows .... and want to count lines in VS project .. isaw one program on codeproject.com that does that for you.


All times are GMT -4. The time now is 03:02.