Batch read only 3rd line from end of file

November 25, 2010 at 04:38:29
Specs: Windows XP, Pentium 4/2GB
How can I read only third line from the end from a text file and save it to a variable?
I need to extract error information form log file, which is contained in 5th token delimited with space (" ") in 3rd line from the bottom of file.

See More: Batch read only 3rd line from end of file

Report •


#1
November 25, 2010 at 05:00:02
@echo off & setLocal EnableDELAYedeXpansion

set N=
for /f "tokens=* delims= " %%a in (myfile) do (
set /a N+=1
)

set /a T=!N!-3
for /f "skip=%T% tokens=5 delims= " %%a in (myfile) do (
set V=%%a
goto :done
)
:done
echo.!V!


=====================================
Life is too important to be taken seriously.

M2


Report •

#2
November 25, 2010 at 05:09:55
Thank you very much, it works great!
How do you do that quick responses? You're awesome!

Report •

Related Solutions


Ask Question