set n=<lines>
for /l %a in (1,1,%n%) do (
for /f "tokens=*" %i in ('find /v /n "" ^< test1.txt ^| find "[%a]"') do (
REM ove prefixed line numbers:
set a=%i
set a=!a:*]=!
echo:!a!)
)
丢弃文本(尾部)的前几行:
set n=<lines>
set file=<file.txt>
set /a n=n+1 >nul
for /f "tokens=*" %i in ('find /v /c "" ^< %file%') do set total=%i
for /l %a in (%n%,1,%total%) do (
for /f "tokens=*" %i in ('find /v /n "" ^< %file% ^| find "[%a]"') do (
REM ove prefixed line numbers:
set a=%i
set a=!a:*]=!
echo:!a!)
)
注:
The head function can also be achieved by fsutil
通过 fc和 comp也可以实现尾部功能