Count number of lines - 'findstr'

How do I count number of lines in a command output?

findstr /r/n "^" | find /c ":"

Above commands will display number of lines output by whatever command (well, nearly whatever) you specify in the front. 

For example: 

C:\>ping localhost | findstr /r/n "^" | find /c ":"
FINDSTR: // ignored

This comes handy if you want to find out how many OUs you have in Active Directory:

dsquery ou  -limit 0 | findstr /r/n "^" | find /c ":"

How many user accounts there are:

dsquery user -limit 0 | findstr /r/n "^" | find /c ":"


dsquery computer -limit | findstr /r/n "^" | find /c ":"

1 comment:

  1. How can we remove the first line FINDSTR: // ignored in the output?