computing
  • 6

FOR Loop To Read BLANK LINES From File

  • 6

Hello all,
I tried to search everywhere but failed to get answer. I would like to read a text file using FOR loop in batch script, but it ignores BLANK LINES. I would like to count/read all lines including BLANK LINES.

example of text file:

abc
def

ghi
jkl
mno

pqr

Now if I use For loop to read this text file, it ignores blank lines and gives me count of total 6 instead of 9 lines.

Any Idea how can I accomplish this task?

Thank you

Share

1 Answer

  1. To count the lines in a file including the blank ones

    find /V /C "" file.txt
    

    • -1