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
12
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 ":"
Computers:
dsquery computer -limit | findstr /r/n "^" | find /c ":"
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
12
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 ":"
Computers:
dsquery computer -limit | findstr /r/n "^" | find /c ":"
Comments
Post a Comment