Sum output from file?
Posted: 02 Jun 2010 05:00
Hello,
I need to sum the output from a file, why this doesnt work i dont know?
The file looks like this:
The %tot% variable is equal to the last value in the file?
Anyone knows why?
EDIT: One more question now while I'm at it, whats the difference between:
//Barty
I need to sum the output from a file, why this doesnt work i dont know?
Code: Select all
set /A tot=0
for /f "tokens=1" %%a in (file.txt) do (
set /A tot=%tot% + %%a
)
echo %tot%
The file looks like this:
Code: Select all
5
3
8
6
4
8
The %tot% variable is equal to the last value in the file?
Anyone knows why?
EDIT: One more question now while I'm at it, whats the difference between:
Code: Select all
echo %var%
echo.%var%
//Barty