How can I get the line count of a text file?

I don't want it to delete the rest or anything but just to quickly report the number of lines the text I just entered is included.

How can I quickly find "the number of lines in this text that include the string I just entered"?

2

4 Answers

In notepad, you can type Ctrl+g to view current line number.
It also at bottom-right corner of status-bar.

2

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.

I found the best option was a cat text |grep text|wc -l with an msys installation.

2

If you copy and paste the text into word you can see the Words, Characters (with and without spaces), Paragraphs and Lines by clicking on the bottom left where it shows the word count preview.

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like