I am trying to filter a large log file. Is there a way to read a line from the log, if the line contains less than 2 characters, delete the entire line from the log using power-script
I have come up with a way of counting characters in the file
Get-Content ./output.txt | ForEach-Object { $_ | Measure-Object -Character } | Out-File count.txt
This counts each line and then outputs the characters counted into another file
And I know how to delete an empty line
Get-Content .\output.txt | where {$_ -ne ""} | Set-Content out.txt
or a line that contains a specific character or string
Get-Content .\in.txt | Where-Object {$_ -notmatch 'STRING'} | Set-Content out.txt
Is there a way to pipe the output and ask "if the count is <=1 delete that line from the log"
Basically
for each line
if line is <= 1 delete line
else leave alone
I hope this makes sense to you guys, I find it hard to get out whats in my head sometimes in a way that makes sense to others. Any help would be much appreciated