samedi 11 avril 2015

Windows FOR /F - Echo each line in file - Spaces in line - FAIL

I have a simple text file and would like to echo each line of the file. This fails if the line has SPACES in it.


Here is the contents of the text file - " t.t " Indented for clarity.



1
2
3
4
5
a.a
This Had Spaces


Here's the failing code :



FOR /F %G IN (t.t) DO (@echo %G)
1
2
3
4
5
a.a
This

FOR /F "usebackq" %G IN (t.t) DO (@echo %G)
1
2
3
4
5
a.a
This


Notes : This is not a batch file - but rather run directly at the WinXP command prompt - hence the % rather than %%


Aucun commentaire:

Enregistrer un commentaire