Well I have that code:
@echo off
FOR /F "tokens=* skip=3" %%A IN (abc.txt) DO (echo.%%A)
pause
In abc.txt:
a
b
c
d
e
f
g
h
i
j
k
l
m
n
ñ
o
p
q
r
s
t
u
v
w
x
y
z
I want to read only the third line and no more...
How can I do that? :/
Well I have that code:
@echo off
FOR /F "tokens=* skip=3" %%A IN (abc.txt) DO (echo.%%A)
pause
In abc.txt:
a
b
c
d
e
f
g
h
i
j
k
l
m
n
ñ
o
p
q
r
s
t
u
v
w
x
y
z
I want to read only the third line and no more...
How can I do that? :/
@echo off
set /a "skip=%~1" || exit /b
if %skip% gtr 0 (set skip=skip=%skip%) else (set skip=)
set "value="
for /f "usebackq %skip% delims=" %%A in ("abc.txt") do (
set "value=%%A"
goto :done
)
:done
echo value=%value%
FOR /F does not support "skip=0"
, hence the if statement before the loop.
Wow! I have solved it:
@echo off
set /a count=6
if defined count for /f "skip=%count%tokens=1*delims=:" %%i in ('findstr /N "^" "abc.txt"') do if not defined value set "value=%%j"
echo %value%
Output: g
:D
This uses a helper batch file called findrepl.bat from - http://www.dostips.com/forum/viewtopic.php?f=3&t=4697
type abc.txt |findrepl /o:3:3
findrepl.bat is a handy addition to your tools.
In this usage it sets the start line and end line to the same number /o:S:E