In Bash, how do I count the number of non-blank lines of code in a project?
There are many ways to do this, using common shell utilities.
My solution is:
grep -cve '^\s*$'
This searches for lines in
An advantage of this method over methods that involve piping into wc
, is that you can specify multiple files and get a separate count for each file:
$ grep -cve '^\s*$' *.hh
config.hh:36
exceptions.hh:48
layer.hh:52
main.hh:39