Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
up vote 5 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 that the sloccount formula requires hasn't been available for some time. – BeeOnRope Sep 20 '14 at 19:27
sudo is unnecessary (and not advisable) when installing homebrew packages. – DC_ Jan 14 at 4:28

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

share|improve this answer

Your Answer


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.