How do I do a "word count" command in Windows Command Prompt

24,910

Solution 1

find command could be used in windows cmd to find line count (with the /c switch), word count etc.

http://rickardnobel.se/counting-lines-in-windows-command-prompt/

Solution 2

The closest I know of is the PowerShell equivalent Measure-Object.

Solution 3

"Find" will be able to do the task similar to word count as RRM told.

Eg.

Query user | find /v /c ""

/v – Show any lines that don’t contain the string of words you specified. /c - Count the number of lines that matches the word in fine.

Query user | find /i "active" /c

/i - Ignore case /c - Count the number of lines that matches the word in fine.

Share:
24,910

Related videos on Youtube

Author by

Nei Mina

Currently a Freshman & Computer Science Student.

Updated on August 13, 2020

Comments

  • Nei Mina over 2 years

    I know the command in Unix/Linux systems is "wc" but that doesn't work in Windows.

  • Nei Mina almost 8 years
    Awesome! I assume there's a version for 64 bit systems?
  • Sphinx
    Sphinx almost 5 years
    Please add correct tags for your question, like bash etc.
  • qqqqq
    qqqqq about 4 years
    In this example is it looking for the word "active"? If I look for count of "fail" in "result.txt": Query user | find /i "fail" /c E:\tests\result.txt

Related