Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a folder full of my code, what shell script can I use to find out the total amount of lines of code?

share|improve this question

2 Answers 2

up vote 3 down vote accepted

A very simple solution would be wc -l ./*, which counts the number of lines in all files, as well as each file individually.

If you want something more sophisticated, use sloccount. You can install it e.g. using Homebrew:

sudo brew install sloccount

Run it on the folder containing the code, like this:

sloccount .

It'll give you lines by programming language and directory.

share|improve this answer
    
If you want per-file counts as well as a total: wc -l ./* –  Dennis Williamson Feb 17 '11 at 5:41
    
@Dennis Thanks, changed my answer. –  Daniel Beck Feb 17 '11 at 5:47
    
I think brew sloccount hasn't worked for a while because microbrew.org/tools/md5sha1sum/md5sha1sum-0.9.5.tar.gz that the sloccount formula requires hasn't been available for some time. –  BeeOnRope Sep 20 at 19:27

If you just want to count the number of lines in text files, try wc -l *.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.