'wc -l' equivelant for Windows… kinda

Came across a cool find today that I can implement in Windows to replicate wc -l. When wanting to count how many lines in a file on Windows, I can use the following.

type test.txt | find /v /c ""

This is saying to count /c all the lines not containing /v nothing "".

test.txt

a
b
c
d
e
g
type test.txt | find /v /c ""
8

Note that it counts the empty line between e and g in test.txt. It would also count any extra lines that do not contain data (carriage returns).

Published by

Rich

Just another IT guy.

Leave a Reply

Your email address will not be published. Required fields are marked *