How would I count the total number of lines present in all the files in a git repository?
git ls-files
gives me a list of files tracked by git.
xargs
will do what you want:
git ls-files | xargs cat | wc -l
But with more information and probably better, you can do:
git ls-files | xargs wc -l
: | git mktree | git diff --shortstat --stdin
Or:
git ls-tree @ | sed '1i\\' | git mktree --batch | xargs | git diff-tree --shortstat --stdin
I was playing around with cmder (http://gooseberrycreative.com/cmder/) and I wanted to count the lines of html,css,java and javascript. While some of the answers above worked, or
pattern in grep didn't - I found here (https://unix.stackexchange.com/questions/37313/how-do-i-grep-for-multiple-patterns) that I had to escape it
So this is what I use now:
git ls-files | grep "\(.html\|.css\|.js\|.java\)$" | xargs wc -l
Try:
find . -type f -name '*.*' -exec wc -l {} +
on the directory/directories in question