Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
3  
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
1  
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 '14 at 19:29

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

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. – j riv Apr 29 '12 at 10:40
2  
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
2  
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 '14 at 4:25
    
This looks like an Useless use of cat. – A.L May 21 '15 at 12:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .