New
#1
How I read a file .txt and put the last line in a variable
People, I am from Brazil. My English is not very well! Sorry.
I need read a file .txt, where, I need put the last line in a variable.
I am tryng find de number of lines and with a FOR /F read line and line.
But not this going right.
@echo off
setlocal enableextensions enabledelayedexpansion
set/p n=<teste.txt
REM ### Here I cat the number of the lines ###
type teste.txt | find /v /c "" <teste.txt >nlinhas
set/p l=<nlinhas
REM ### Variable that sum ###
set num=0
REM ### Read line and line ###
FOR /F %%n in (teste.txt) do (
if %num%==%l% (
echo %%n
goto :fim
)
set/a num=num+1 <== Where I put this code, occurs syntax error
)
endlocal