How can I get the line count of a text file?
In notepad
, you can type Ctrl+g to view current line number.
It also at bottom-right corner of status-bar.
This can be done natively in Windows, using the command prompt:
find /c "string to find" "mytextfile.txt"
findstr
is more advanced (supports regex) but doesn't support printing line count. You could pipe its output to find
:
findstr "string to find" "mytextfile.txt" | find /c /v ""
find /c /v
means count lines not containing. From testing, the empty string to find (""
) never actually occurs in the piped input from findstr
, so its a safe value to use.