Reputation: 1
Please help in syntax to do find string to search for a paragrah start with string and end with another string. Ex: Supporse there is a file with member with id : 1234 is processed successfully . And here i want to search for certain lines starts with member and end with processed successfully. Here I am using below code(for reference). Please let me know any confusion into it
for /f "delims=" %%A in ('
findstr /B "member " /E "processed successfully." abc.log
') do set "check=True"
Upvotes: 0
Views: 2212
Reputation: 30103
Findstr
command using Regular Expressions (Search for patterns of text)
findstr /R "^member\ .*processed\ successfully\.$" abc.log
or without Regular Expressions: pipe findstr
output to another findstr
as follows:
findstr /B /C:"member " abc.log | findstr /E /C:"processed successfully."
Note: you need to escape the |
pipe character if used in for /F
loop against the results of piped commands as follows:
for /f "delims=" %%A in ('
findstr /B /C:"member " abc.log ^| findstr /E /C:"processed successfully."
') do set "check=True"
Regular Expressions:
FINDSTR
support for regular expressions is limited and non-standard, only the following metacharacters are supported:. Wildcard: any character * Repeat: zero or more occurances of previous character or class ^ Line position: beginning of line $ Line position: end of line [class] Character class: any one character in set [^class] Inverse class: any one character not in set [x-y] Range: any characters within the specified range \x Escape: literal use of metacharacter x \<xyz Word position: beginning of xyz\> Word position: end of word
Upvotes: 1