Reputation: 91
set var=1
for /f "skip=%var% tokens=*" %%a in (any.txt) do (echo %%a)
works fine.
But when,
set var=0
for /f "skip=%var% tokens=*" %%a in (any.txt) do (echo %%a)
won't work. My purpose is to skip line 0 (which means don't skip).
Error: tokens=*"
was unexpected at this time.
Is there any ways to make it work?
Upvotes: 1
Views: 612
Reputation: 34919
set /P var="Enter number of lines to skip: "
if %var% gtr 0 (set "skip=skip=%var% ") else (set "skip=")
for /f "%skip%tokens=*" %%a in (any.txt) do (echo %%a)
Upvotes: 4