Per this answer I was attempting to use findstr to locate a string (a name) inside some HL7 log files in a directory. Findstr was getting 0 results, but Find returned plenty. I played around with the syntax of my findstr command, but couldn't get it to return a result. Note, as these are HL7 files, the name is surrounded by symbols (|, ^, etc.):

D:\logs>findstr /l /m /c:"Test" *.*


I assume the lack of output means 0 results. Meanwhile:

D:\logs>find /c "Test" *.*

---------- LOG1.LOG: 0

---------- LOG2.LOG: 4

---------- LOG3.LOG: 0

---------- LOG4.LOG: 0

---------- LOG5.LOG: 8

---------- LOG6.LOG: 0

---------- LOG7.LOG: 18

So there are plenty of results. Why didn't Findstr find any files?

  • Can you post a sample of the log file so that I can reproduce? – djangofan Aug 17 '12 at 20:47
  • @djangofan I'm having issues ginning up fake files for some reason. Making a small text file with the bare minimum of what I think is a sufficient simulation (e.g. "|Test^Foo") ends up working with findstr. – Keen Aug 17 '12 at 21:12
  • I think with those special characters, like '^', you need to enable delayed expansion in your script. This script is an example I made that uses both FIND and FINDSTR.exe : thegreenoak.blogspot.com/2012/01/… . – djangofan Aug 20 '12 at 17:34

Your Answer

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

Browse other questions tagged or ask your own question.