Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

Is there a tool that quickly finds "the number of lines in this text that include the string I just entered"?

share|improve this question
2  
Please specify how your question is different from a text editor? Most text editors show the current line and thus allow you to how many lines the document has. –  Tom Wijsman Apr 3 '12 at 8:23
    
This is useful when files are large enough that they cannot or should not be loaded into memory. In a *nix world, I would go to wc to do this, which reads files as streaming input (and stdin). The find solution below is similar. A text editor would read the entire file contents to memory. –  tommy_o Jun 12 at 19:29

3 Answers 3

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

share|improve this answer
    
Weird. There's no status bar (greyed out in drop down menu) here. Windows 7. –  leladax Apr 29 '12 at 10:40
1  
Status bar will disabled if you wrap lines. Notepad cannot calculate the line number. –  kev May 1 '12 at 1:50
up vote 0 down vote accepted

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

share|improve this answer
1  
If you have grep, then an even better option would be grep PATTERN FILE | wc -l or, even better, grep -c PATTERN FILE. –  Jay Allen Jan 22 at 4:25

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.