Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » How to skip the first two lines, the last two lines, and blank lines, and read the first column of a file?
View 745 Replies 4
Credits 28 Posts 10 Joined 2007-02-19 09:47 19-year member UID 79788 Gender Male
Status Offline
for /f "skip=2 tokens=1" %%1 in (result.txt) do echo %%1>>new.txt
SET A=1
FOR /F "TOKENS=1* DELIMS=:" %%A IN ('FINDSTR /N .* new.txt') DO (
echo %%B
SET/A B=!A!%%100
IF !B! EQU 0 (ping -n 15 127.1>NUL)
SET/A A+=1
)
This won't skip the last two lines or blank lines.
Credits 11,386 Posts 4,938 Joined 2006-07-23 17:10 19-year member UID 59080
Status Offline
There is a difference between first skipping the first two lines and then skipping blank lines, and first skipping blank lines and then skipping the first two lines. OP, please describe the problem clearly.