This will include whitespace and everything.
If you want to exclude whitespace, you'll need to add some sed goodness as well:
find . -type f -name '*.java' | xargs cat | sed '/^\s*#/d;/^\s*$/d' | wc -l
If you want to exclude other stuff, add some more sed goodness to the pipe stream before piping it to wc.
Want multiple extensions?
find -E . -regex '.*\.(java|dart|xml|css|xml|js|jsp|html)' -type f | xargs cat | sed '/^\s*#/d;/^\s*$/d' | wc -l
Based on something I've found on StackOverflow, you can also use git to count lines, although this will give you lines committed and not any fine-grained control on what you include and exclude:
git log --format='%aN' | sort -u | while read name; do echo -en "$name\t"; git log --author="$name" --pretty=tformat: --numstat | awk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf "added lines: %s, removed lines: %s, total lines: %s\n", add, subs, loc }' -; done
Otherwise I used to use an IntelliJ plugin, but it seems to have disappeared after upgrading to version 15.
Jan Vladimir Mostert
Idea Incubator
This will include whitespace and everything. If you want to exclude whitespace, you'll need to add some
sedgoodness as well:If you want to exclude other stuff, add some more
sedgoodness to the pipe stream before piping it towc.Want multiple extensions?
Based on something I've found on StackOverflow, you can also use git to count lines, although this will give you lines committed and not any fine-grained control on what you include and exclude:
Otherwise I used to use an IntelliJ plugin, but it seems to have disappeared after upgrading to version 15.