The below batch script helps to read the selected trailing lines from Log File

@echo off
cls
setlocal EnableDelayedExpansion
set "cmd=findstr /R /N "^^" C:\Users\Mugil\Desktop\test.txt | find /C ":""

for /f %%a in ('!cmd!') do set totalLines=%%a
rem echo "totalLines-"%totalLines%


@set linesToConsider=4
set /a lineToStart="%totalLines%-%linesToConsider%" 

rem echo "lineToStart-"%lineToStart%

set content=
for /f "skip=%lineToStart% delims=" %%i in ('type C:\Users\Mugil\Desktop\test.txt') do set content=!content! %%i


@echo "content - "%content%


If NOT "%content%"=="%content:SUCCESS=%" (
    echo Build Successful
) else (
    echo Build Failed
)

pause

Comments are closed.