In count (non-blank) lines-of-code in bash they explain how to count the number of non-empty lines.
But is there a way to count the number of blank lines in a file? By
Another way is:
grep -cvP '\S' file
-P '\S'
-v
-c
If your grep doesn't support -P option, please use -E '[^[:space:]]'
-P
-E '[^[:space:]]'