Question

HI,

I want to display datas in text file. Here i have Listfile.txt and want to display each line using batch file. How to do this with looping. Below is my code

for /f "tokens=* delims= " %%a in (Listfile.txt) do (
  set /a N+=1
  set v!N!=%%a
)
set hostname=!v1!
echo %hostname%
pause

Data in Listfile.txt:

4mLinuxMachine.cpp
ShutdownPanel.cpp
windows.cpp

How to display each using hostname variable

Please help

Was it helpful?

Solution

If you just want to display each line of the text file, try this:

FOR /F "tokens=1"  %%a IN (Listfile.txt) DO (
  ECHO %%a
)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top