Reputation: 11
I am not good in Windows, and asking the master here.
I have a file which contains:
Line x: abc Line x+1: def
I need to find the strings of abc and def and return as out output. Thanks
And limited to x line and x+1 line. Thanks
Upvotes: 0
Views: 1327
Reputation: 11
I see you already found the "findstr" command in Windows, but unfortunately, the "findstr" command does not support to print the next (or previous) lines of the match.
You could use PowerShell "Select-String" with "-Context" parameter.
E.g: Your file "test.txt" has: Line x: abc Line x+1: def
To print:
abc
def
as the output, you could use following command with PowerShell:
Get-Content test.txt | Select-String -Pattern abc -Context 0,1
Upvotes: 1