4

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

7

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.

1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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