Solved The ECHO command echo only show me the last line of my file

March 26, 2013 at 08:25:01
Specs: Windows 7

I want to show out of the console each line from a file. I try this:

findstr /v /b /c:" " <%1>toto for /f "tokens=*" %%a in (toto) do set co=%%a echo. %co%

Also this one:

findstr /v /b /c:" " <%1>toto for /f "tokens=*" %%a in (toto) do (set co=%%a echo. %co% )

But the first way shows me only the last line of file and the second one doesn't show me anything.

Someone can explain me what's wrong in these latter and how to get in the 'co' variable each line printed on the console?

Thanks


See More: The ECHO command echo only show me the last line of my file

Report •

#1
March 26, 2013 at 08:42:46
✔ Best Answer
To display the whole content of a file type at prompt

more filename

About what is wrong in your cumbersome statement be aware to use environment constants inside a FOR loop you need to set up the dynamic expansion by the SETLOCAL EnableDelayedExpansion command and then mark the variable as !var! NOT %var%.

Report •

#2
March 26, 2013 at 08:54:26
Thanks, it works!
Here what I have written for :

@echo off & setLocal
SETLOCAL EnableDelayedExpansion
set co=%co%
findstr /v /b /c:" " <%1>toto
for /f "tokens=*" %%a in (toto) do (set co=%%a
echo !co!
echo 1


Report •

#3
March 26, 2013 at 09:02:32
might this work?
findstr /v /b /c:" " %1>toto
for /f "tokens=*" %%a in (toto) do echo %%a

:: mike


Report •

Related Solutions

#4
March 26, 2013 at 09:35:09
No, it does not work Mike!

Report •

Ask Question