I have two files:
1.txt:
abc
def
2.txt:
abc
Please note that 2.txt contains only 3 characters, no empty lines. Now if I do:
findstr /S /I /L /A:02 "abc" *
I get this result:
1.txt:abc
2.txt:abc
Which is what I expect. However after renaming 1.txt to uno.txt and 2.txt to duo.txt (thus changing file search order) and running the same command I get this:
duo.txt:abcuno.txt:abc
Result is in one line and I was expecting two lines as before. Of course if I add new line at the end of duo.txt then output is ok but how to do that without modifing files? Is there some "force result in new line" option in findstr?
You could try using a FOR
loop to go through the files and pipe the contents of each to FINDSTR
.
Something like this:
@ECHO OFF
FOR /R %%f IN (*.txt) DO (
TYPE %%f | FINDSTR /S /I /L "abc"
)