There are many situation where we need to know whether a file conatins blank line. If the file is small we can manually open it and see . But if it is very large it will be easy to find it by wrtitng a small script . Here I am using awk to find the number of blank lines in a file.
Let say the file abc.txt contains the following data.
> cat abc.txt
abc
abc
abc
abc
[EOF]
Here there are 9 lines in the file out of which 5 line are blank lines.The below sctipt will find the number of blank line in this file.
> cat abc.txt | awk '/^$/{ ++count } END { print "Number of blank lines is : " count}'
Output
Number of blank lines is : 5
Comments
Post a Comment