Search code examples
windowscmdfindstr

find /C "A" results in "find: 'A': No such file or directory"


I am trying to count lines in a file following the answer here, e.g. using find /C, but all I see in console is:

find: '/C': No such file or directory
find: 'A': No such file or directory

I have a simple "TEST.txt" file with three As and three Bs, all in new lines:

$ type TEST.txt
A
A
A
B
B
B

findstr seems to work, but it cannot return counts:

$ type TEST.txt | findstr "A" 
A                             
A                             
A   

find does not work:

$ type TEST.txt | find "A"
find: 'A': No such file or directory

What am I missing?

PS: The whole example from 1 does not work as well:

$ findstr /R /N "^" TEST.txt | find /C ":"
find: '/C': No such file or directory
find: ':': No such file or directory

Edit:

As it might be important to understand what is happening: I am using a ConEmu terminal.


Solution

  • Do you have the ConEmu binary directory containing find.exe in the PATH before the Windows directory containing find.exe?

    If you cannot change the PATH variable, you can specify the full path to the Windows find with %windir%\System32\find.exe.