How to measure the number of lines of code in a project
Example for "m" and "h" files. Open your terminal app, go to the folder of your project and type this command:
find . -name "*.[hm]" -print0 | xargs -0 wc -l
Change the ".m" and ".h" extensions to your liking ;-)
For words
find . -name "*.[hm]" -print0 | xargs -0 wc -w
For characters
find . -name "*.[hm]" -print0 | xargs -0 wc -m
Side note
As noted by alhafoudh there is a more elegant way of doing this by using the cloc
command. It's not installed by default on OS X though. It can be found here or installed via Homebrew.
Written by Sendoa Portuondo
Related protips
2 Responses
What about using cloc
command?
over 1 year ago
·
Really nice command! Didn't know it. It's not installed on OS X by default though. I installed it through Homebrew and it works like a charm. Pretty cool!
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Php
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#