Reputation: 21
$result = Get-Content -Path D:\out.txt
$grepString = $result | Select-String -Pattern "startpoint of the string"
Write-Host $grepString
I used this code but it is printing only one line(when it get \n), But I want my output in containing rest of the lines
Upvotes: 0
Views: 459
Reputation: 174900
You could use the .Where()
extension method in SkipUntil
mode:
$result = Get-Content -Path D:\out.txt
$filteredResults = $result.Where({$_ -match "startpoint of the string"}, 'SkipUntil')
$filteredResults
is now an list of the input strings from the first match till the end.
Upvotes: 1