Hello Everyone,
I have a pretty basic question. I have a text file that contains a lot of values. I want to parse out certain values and leave the rest.
This is the code I'm currently using, and it works, but the problem is, that instead of just ignoring lines that match the criteria, it's adding Blank lines to the new file for those lines that match the critera, The simple solution would be to parse out empty lines, but I actually need the correct new lines in the output.
$temp = "C:\ErrorTool\ETestShort.txt"
$temp2= "C:\ErrorTool\ETestShort_Remaining.txt"
[String[]]$OUtputStuff = @()
[String[]]$tempValue = Get-Content $temp | Select-String 'ERROR:Null' -NotMatch
foreach ($line in $tempValue)
{
if ($line -notmatch "0>ERROR:")
{$OUtputStuff+=$line}
}
($OUtputStuff) | Out-File $temp2
The input text file is similar to so: Error: Blah blah Error:Null Error: Blah blah Error: Blah blah The expected result would be: Error: Blah blah Error: Blah blah Error: Blah blah Error: Blah blah Error: Blah blah Error: Blah blah (Extra Empty line here) Error: Blah blah Error: Blah blah Any ideas what I'm doing wrong?
Error: Blah blah
The actual result is :