If a.txt contains
a b c
abc
The command for /f %开发者_JAVA技巧x in (a.txt) do echo %x
is printing
a
abc
What am I doing wrong?
for /f "tokens=*" %x in (a.txt) do @echo %x
The @echo will prevent the echo line from being printed
for /f "delims=|" %i in (a.txt) do @echo %i
Inside "delims=|" you can use any character for the delimiter that is not part of the file
@echo off
setlocal
for /F "usebackq tokens=1-3 delims= " %%a IN ("a.txt") DO (
if not "%%a"=="" echo.%%a
if not "%%b"=="" echo.%%b
if not "%%c"=="" echo.%%c
)
Tokens - the set of chars delimited by one of the delim char.
You can specify many delim chars, i.e. delims= .,
精彩评论