Hi,
I need a script that get a log file as an input a looking for a line with "fatal error" if he find it print all this line to another output file.
Thanks in advance....
log parsing
Moderator: DosItHelp
Re: log parsing
This might help you:
penpen
Edit: Corrected the code.
Code: Select all
@echo off
setlocal
set "logFile=test.txt"
set "outFile=out.txt"
(
for /F "tokens=* delims=" %%a in ('findstr /C:"fatal error" "%logFile%"') do echo(%%a
) > "%outFile%"
endlocal
goto :eof
penpen
Edit: Corrected the code.
Last edited by penpen on 07 Aug 2013 04:48, edited 1 time in total.
Re: log parsing
Hi,
Thanks i did'nt understand 100% what it's print in th output file beacuse i saw there also line with warning indside.
I just want to print the line with "fatal error" inside.
Thanks i did'nt understand 100% what it's print in th output file beacuse i saw there also line with warning indside.
I just want to print the line with "fatal error" inside.
Re: log parsing
Sorry, i have forgotten to use /C:, so i added it to the code above.
Without the C option findstr outputs all lines with "fatal" or "error", the space then is treated as a separator.
When using the C option findstr writes all lines with "fatal error" as one search string to the output.
Btw: If you want to ignore if characters are lower case or upper case, you might use the option /I.
penpen
Without the C option findstr outputs all lines with "fatal" or "error", the space then is treated as a separator.
When using the C option findstr writes all lines with "fatal error" as one search string to the output.
Btw: If you want to ignore if characters are lower case or upper case, you might use the option /I.
penpen