Count the number of blank lines at the end of file

greptext processingwc

I have a file with blank lines at the end of the file.
Can I use grep to count the number of blank lines at the end of the file with the file name being passed as variable in the script?

Best Answer

If the blank lines are only at the end

grep  -c '^$' myFile

or:

grep -cx '' myFile
Related Question