Otinane
Otinane

Reputation: 29

Find empty lines in a .txt using .bat/cmd

I have a txt file that has some lines that are empty How can i get the numbers of lines that are empty in a .txt file?

I would like to do this using either .bat or cmd line

Upvotes: 0

Views: 1796

Answers (2)

foxidrive
foxidrive

Reputation: 41234

This will count blank lines containing no text, and no spaces etc.

findstr /n "^$" "file.txt" |find /c /v ""

Upvotes: 0

Stephan
Stephan

Reputation: 56180

findstr /n /v "." file.txt

/n gives the lines with leading linenumbers (or just linenumbers for empty lines)

/v only list lines that DOESN'T contain ...

"." ... any char in

file.txt

Upvotes: 1

Related Questions