Another way is:
grep -cvP '\S' file
-P '\S'
(perl regex) will match any line contains non-space-v
select non-matching lines-c
print a count of matching lines
If your grep doesn’t support -P
option, please use -E '[^[:space:]]'
Another way is:
grep -cvP '\S' file
-P '\S'
(perl regex) will match any line contains non-space-v
select non-matching lines-c
print a count of matching linesIf your grep doesn’t support -P
option, please use -E '[^[:space:]]'