For /F problem - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

For /F problem

WillqwertyWillqwerty Posts: 4Member
I am running Vista sp2 and am having trouble with the FOR /F command. Ill show you my problem:

So far i have written this as a test for a larger program to come, but that doesn't matter

My program:

@echo off

For /F "tokens=1 delims= " %%G IN (Lines.txt) DO Set var=%%G

echo %var%

pause
exit

Lines.txt refers to a text file that looks like this:

a
b
c
d


If my understanding of FOR /F is correct it should only be able to extract 'a' & this is what i want it to do, but it keeps returning d, why is this, can i change it? Any help would be greatly appreciated!

Will

Sign In or Register to comment.