batch-filefindstr

Clean a log file to keep only specific lines with known substrings


I want to create a clean log with just the 'warning', 'hint', 'error' and 'fatal' lines, like this:

findstr /I /C:"Warning:" /C:"Hint:" /C:"Error:" /C:"Fatal:" log_full.txt >> log_clean.txt

But this doesn't work, a lot of lines without these strings still appear.


Solution

  • Trying to found a solution one suggest appers, remove the extra spaces created in file by the builder with this:

    powershell -Command "(Get-Content log_full.txt) -replace '\s+$','' | Set-Content log_full.txt"
    

    On the first time i try this without powershell but doesn't works, qith the powershell was possible generate a clean log of warnings, hint and erros to put this ina a devOps tool to avaliate the pull request of developers