0

Consider a large log file containing data; the goal is to capture all rows containing either (TRxxxx), where the x's can be anything from 0000 to 9999, and also capture all rows containing "error". I have to do this using the cmd, so I have tried to apply findstr.

One issue I have run into is that sometimes there are successful runs stating (TRxxxx), such as: "(TR1234) Power '60 KB' has been deployed to version '9'". I do not want these, only the ones that have failed.

I considered using regex to match everything containing "(TRxxxx)" or "error", but not "(TRxxxx) the deployment has been successful".

I tried to do this using the following: findstr /R "^((?!has been deployed).*$)|.*error.*|\(TR[0-9]{4}.*\)" test.log but it still captures "has been deployed", and I think overall it's a broken mess.

Test input to make it easier to work with:

(TR3919) Power '1' has been deployed to version '1'       <-- no match
(TR9102) Power '2' has NOT been deployed to version '2'   <-- match
Random text and l3773r5, with a big error...              <-- match
(TR1337) complicated                                      <-- match
(TR1239) error                                            <-- match
JCJ
  • 303
  • 3
  • 13

0 Answers0