|
Answer» i am writing a batch script to compare the time in logs with the system time to check if the process is getting delayed
the last log ENTRY generated will be at the end of the FILE with time included i need to go that line. is there anyway to do it?One way to get the last line would be to read the file counting the number of lines. Once you have a count, you can re-read the file, skipping n-1 lines and read the last line for processing:
Code: [Select]@echo off set count=0 for /F %%i in (time.log) do ( call set /a count=%%count%%+1 )
call set /a count=%%count%%-1
for /f "skip=%count% tokens=* delims=" %%i in (time.log) do ( echo %%i )
If need be, FIXUP the second for statement to parse out the info you need. I ARBITRARILY chose time.log as the file name; change as needed.
Good luck.
Need more info as to where the time info is on that line and in what format.a better way is to just set the variable Code: [Select]for /f %%i in (time.log) do ( set lastline=%%i ) echo %lastline%
|