2

I am running command,

Find /C /I "pass" "log.txt" > output.txt

output am getting,

---------- LOG.TXT: 2

Getting this output because, there is two time the word "pass" comes in log.txt file.

expected output,

2

I don't wanna the file name to be included in output file. I need only the count. I remember something called /NoLogo command that works But, donno the exact command or where to use it. Kindly help me.

  • Did you get a chance to look over the answer I provided below. Circling back around to see about closing the loop if nothing else and this as an FYI.... i.imgur.com/OZho1tT.png – Pimp Juice IT Mar 24 at 23:34
1

Two ways to omit the file name within the output of the find command when getting a count for line matches without needing to loop and using delims and such is to. . .

1. By redirecting the file over to the find command to have its lines searched using that method of command redirection e.g. command < filename

  Find /C /I "pass" < output.txt

2. Use the type command against the file and then pipe that over to the find command to use that method of command redirection.

 type output.txt | Find /C /I "pass"

Example Output (two matching lines)

2

Supporting Resources

| improve this answer | |
  • I believe these two methods do the exact same thing essentially. Maybe there are some batch experts that know otherwise though. – Pimp Juice IT Dec 27 '19 at 2:25
0

Could be someting like this:

@echo off
for /f "tokens=2 Delims=:" %%a in ('Find /C /I "pass" "log.txt"') do for /f %%b in ("%%a") do echo %%b>output.txt
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.