0

Assuming that i've the following txt.file:

Jenkins Build Received: Request type: ScanRequestRequest ID: 2Assessee name: Jenkins.ZIP" jenkins_logs.txt

This build happens every weekend and the ScanRequestRequest ID number (in this case is number two) is always different.

What is the best approach to use the findstr command where? I've tried some examples but without any success:

findstr /C:"Jenkins Build Received: Request type: ScanRequestRequest ID: *Assessee name: Jenkins.ZIP" jenkins_logs.txt

And:

findstr /C:"Jenkins Build Received: Request type: ScanRequestRequest ID: [0-9]Assessee name: Jenkins.ZIP" jenkins_logs.txt

I saw too the findstr r/ option but i need the program catch this string literally (the jenkins_log is a file with too many lines (over 10000).

I'm new with this thing of batch. Thanks in advance.

Compo
  • 36,585
  • 5
  • 27
  • 39
Morais
  • 133
  • 2
  • 11
  • 2
    So what do you want to do? You explain, but do not show what you want to achieve – Gerhard Mar 15 '19 at 13:08
  • you need a regex to search for this, which you must call with `findstr /r`. But what do you mean by "literally"? Obviously if the string is match, the whole literal line must be printed – phuclv Mar 15 '19 at 13:53
  • @GerhardBarnard i need to use this string in a if condition that i have (if the string exist, starts another batch), if not (close the program). The if condition is always returning false because the ID number is always different. – Morais Mar 15 '19 at 14:33
  • @phuclv I've tried findstr /r but never result because he shows everything. And example: 03/14/19 21:17:57Jenkins Build Received: Request type: ScanRequestRequest ID: 2Assessee name: Jenkins.ZIP03/14/19 23:17:57Jenkins Build Finished: Request type: ScanRequestRequest ID: 2Assessee name: Jenkins.ZIP03/14/19 23:18:10Jenkins Build Received: Request type: ScanRequestRequest ID: 3Assessee name: Jenkins_2.ZIP03/15/19 03:11:32Jenkins Build Finished: Request type: ScanRequestRequest ID: 3Assessee name: Jenkins.ZIP_2 I don't want this. – Morais Mar 15 '19 at 14:46
  • then it's a duplicate of [Findstr - Return only a regex match](https://stackoverflow.com/q/40780784/995714) – phuclv Mar 15 '19 at 14:54
  • 1
    `/R` and `/C` can be used together, which is what you need here; the best way to match a single decimal digit is `[0123456789]` (since `[0-9]` might also match characters `²` and `³`); to match one or more digits, use `[0123456789][0123456789]*`... – aschipfl Mar 15 '19 at 15:07
  • @aschipfl A huge thanks for you my friend! It's working! :D – Morais Mar 15 '19 at 15:33

0 Answers0