Reputation: 15863
As the title says how i can calculate the total number of lines in a source code folder using bash commands
Upvotes: 10
Views: 14167
Reputation: 47572
Use sloccount
"SLOCCount", a set of tools for counting physical Source Lines of Code (SLOC) in a large number of languages of a potentially large set of programs
Upvotes: 23
Reputation: 1921
Already been answered, just giving another way using awk
which you'll definitely have.
cat *.ext | awk 'BEGIN{i=0;} {i++;} END{print "Lines ", i}'
I only also suggest this because it can be easily edited to add patterns (such as comments) for lines that you don't want to count.
Upvotes: -1
Reputation: 44376
My suggestions would be
find
command as in Barti's answer to locate all the filessed
or something to strip out all the commentsSLOC is a very, very misleading way to measure software. Bill Gates said it was like estimating the quality of an aircraft by weight, and it may be the only helpful thing he ever said.
Upvotes: 1
Reputation: 4017
This will count empty lines as well, but it's easy. Go to the specific directory you wanna check and do
find . | wc
Upvotes: -1
Reputation: 10299
You could try something like:
find . -name "*.java" -exec cat {} \; | wc -l
Upvotes: 3