1
1
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" *.*
D:\logs>
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 – 2012-08-17T20:47:10.037
@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 – 2012-08-17T21:12:51.670
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 : http://thegreenoak.blogspot.com/2012/01/dos-batch-script-to-edit-property-files.html .
– djangofan – 2012-08-20T17:34:00.697