2016年12月1日 星期四

[Linux 常見問題] Count number of blank lines in a file

Source From Here
Question
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 blank line I also mean lines that have spaces in them.

How-To
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


沒有留言:

張貼留言

[Git 常見問題] error: The following untracked working tree files would be overwritten by merge

  Source From  Here 方案1: // x -----删除忽略文件已经对 git 来说不识别的文件 // d -----删除未被添加到 git 的路径中的文件 // f -----强制运行 #   git clean -d -fx 方案2: 今天在服务器上  gi...