Reputation: 9836
If I have a text file call text.txt and I have this code to read it.
@ECHO OFF
SetLocal EnableDelayedExpansion
for /f "delims=" %%x in ('type text.txt') do (
set "Var=%%x"
ECHO !Var!
)
pause
How could I only display the third line of the text file. Thanks.
Upvotes: 1
Views: 73
Reputation: 70951
@ECHO OFF
SetLocal DisableDelayedExpansion
for /f "usebackq skip=2 delims=" %%x in ("text.txt") do echo %%x & goto done
:done
pause
Skip two lines, write the third and exit the for loop
Upvotes: 1