中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-09-25 04:53
47,813 topics / 349,918 posts / today 1 new / 48,274 members
DOS批处理 & 脚本技术(批处理室) » How to skip the first two lines, the last two lines, and blank lines, and read the first column of a file?
Printable Version  856 / 4
Floor1 ngela Posted 2007-04-27 22:32
初级用户 Posts 10 Credits 28
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.

Is there any way to do it?

Can the file be read only once?
Floor2 lxmxn Posted 2007-04-27 23:43
版主 Posts 4,938 Credits 11,386
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.
Floor3 ngela Posted 2007-04-28 12:04
初级用户 Posts 10 Credits 28
First skip the first two lines, then skip the last two lines and blank lines.

The blank lines are at the very end of the file. There are two lines.
Floor4 ngela Posted 2007-04-29 00:27
初级用户 Posts 10 Credits 28
The purpose is to read the first column between the first two lines and the last two lines. The blank lines are after the last two lines.
Floor5 lxmxn Posted 2007-04-29 04:51
版主 Posts 4,938 Credits 11,386
Since the last two lines of the file are blank lines, the for command can ignore them automatically.
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023