The for
command with the /F
switch is used to parse lines of text strings (literal strings, read from text files, or retrieved from command line output) and to parse each to one or more tokens.
How can I get a line of text as it is, without any characters replaced nor any lines ignored?
I know that for /F "delims=" %L in (*) do echo."%L"
returns each parsed (non-empty) line unedited. However, since the eol
option defaults to ;
, every line starting with that character will be ignored.
If I use for /F "tokens=* eol=" %L in (*) do echo."%L"
, I disable the eol
option [Edit: This claim is not true, "eol="
does not disable the eol
option, but it defines "
as the eol
character!], but the delims
option defaults to space and tab, so any leading spaces and/or tabs become removed.
(Use %%L
within batch files. The *
stands for any valid source of text string here.)
So my question in other words: is there a way to specify no delims
and no eol
characters?
I tried to specify two option strings ("eol=" "delims="
) but such results in a syntax error. So does option string "eol=delims="
.
Note: This problem does not persist when tokenizing, that is, when the delims
option is set, because that seems to be applied with a higher priority than eol
(strangely but luckily), so you can "hide" eol
behind delims
by specifying a delims
character also as eol
.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…