eol=; tokens=*
Posted: 01 Jan 2015 17:11
Happy 2015!
Has anyone else noticed this strange behaviour?
It seems eol is applied after delims and tokens. Change "tokens=*" to "delims=" and run the program again to see what I mean. Just one more thing to be mindful of when you’re processing lines of text with a for /f loop!
BFN!
- SB
Has anyone else noticed this strange behaviour?
Code: Select all
@echo off & setlocal enableextensions disabledelayedexpansion
for /f "delims=:" %%N in (
'findstr /bln __DATA__ "%~dpnx0"
') do set lino=%%N
for /f "usebackq skip=%lino% eol=; tokens=*" %%A in (
"%~dpnx0") do echo([%%A]
endlocal & goto :eof
__DATA__
straightforward line 1
; commented-out line 2
indented text line 3
; indented comment line 4
It seems eol is applied after delims and tokens. Change "tokens=*" to "delims=" and run the program again to see what I mean. Just one more thing to be mindful of when you’re processing lines of text with a for /f loop!
BFN!
- SB