Hello, please sign in or register
You are here: Home

Project size and line count

As a software developer/project manager you should really know how much code you and others are writing. As to how much of a manageability problems those scripts you write today are likely to cause in the future.

Personally i think simplicity and methology are what makes a developer great. Being able to write a badass script with the fewest lines of code.

Unfourtunatly these following methods will not exclude coding comments.

These functions use the find, grep and wc commands under linux.

cd to the project directory

cd /project/

Number of files in project?

find ./  | wc -l

Number of Lines in Project

find ./ -type f  -print0 | xargs -0 wc -l

Size of project in bytes

find ./ -type f  -print0 | xargs -0 wc -c

In the above examples we use the argument -print0 option with `find` and the argument `-0` with xargs to format the filename so that white spaces are properly escaped. i.e. Spaces in the returning filenames are escaped when parsed to wc for line counting. Otherwise wc will miss interpret the file path and consider the single argument as two arguments etc..

Match file types

In the above three methods add the {{{-regex}}} option before the {{{-print0}}} e.g.

find ./ -type f -regex .*\.php -print0 | xargs -0 wc -l

WIll match all files which end with ".php" and print the total number of lines.

 

Comments

Title*
Comment

Prove you are not a robot

To prove you are not a robot, please type in the six character code you see in the picture below
Security confirmation codeI can't see this!
Contact
Name*
Email never shown*
Home Page

Author

Andrew Dodson
Since:Feb 2007

Comment | flag

Categories

Bookmark and Share