China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

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联盟论坛
The time now is 2026-07-29 03:25
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » I want to delete the lines starting with p, c, - in the txt... View 2,368 Replies 17
Original Poster Posted 2007-02-10 21:49 ·  中国 辽宁 大连 联通
初级用户
Credits 86
Posts 31
Joined 2007-01-09 13:30
19-year member
UID 75960
Gender Male
Status Offline
I want to delete them.
Lines starting with p, c, - should not be included.
;)


-------------------------------------------------------------------------------
Performing Time: 2/8/2007 10:29:46
Complete In 0 Hours 0 Minutes 15 Seconds.
-------------------------------------------------------

Using eol seems a bit troublesome.
There should be other methods.

[ Last edited by FBOAR on 2007-2-10 at 08:50 AM ]
Floor 2 Posted 2007-02-10 22:08 ·  中国 河北 廊坊 三河市 移动
金牌会员
★★★★
Credits 2,725
Posts 1,160
Joined 2006-09-23 12:00
19-year member
UID 63486
From 河北廊坊
Status Offline
@ech oof

for /f "eol=- delims=%" %%i in ('findstr /i /v "test.txt"') do @echo %%i

pause
三人行,必有吾师焉。 学然后知不足,教然后知困,然后能自强也。
Floor 3 Posted 2007-02-10 22:10 ·  中国 河北 廊坊 三河市 移动
金牌会员
★★★★
Credits 2,725
Posts 1,160
Joined 2006-09-23 12:00
19-year member
UID 63486
From 河北廊坊
Status Offline
ororjustsimplynotuseeol

@echo off

for /f "delims=" %%i in ('findstr /i /v "p c -" test.txt') do @echo %%i

pause
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
FBOAR +2 2007-02-10 22:43
三人行,必有吾师焉。 学然后知不足,教然后知困,然后能自强也。
Floor 4 Posted 2007-02-10 22:43 ·  中国 辽宁 大连 联通
初级用户
Credits 86
Posts 31
Joined 2007-01-09 13:30
19-year member
UID 75960
Gender Male
Status Offline
Why doesn't my way work?

@echo off
cd.>xxxx.txt
setlocal enabledelayedexpansion
for /f "delims=" %%i in ('findstr /i /v "p c -" test.txt') do @echo %%i
set var=%%i
echo !var!>>xxxx.txt
Floor 5 Posted 2007-02-10 22:51 ·  中国 河北 廊坊 三河市 移动
金牌会员
★★★★
Credits 2,725
Posts 1,160
Joined 2006-09-23 12:00
19-year member
UID 63486
From 河北廊坊
Status Offline
Don't understand why you need to enable variable delay?

@echo off
cd.>xxxx.txt
for /f "delims=" %%i in ('findstr /i /v "p c -" test.txt') do echo %%i>>xxxx.txt



If you must use variable delay, the code is as follows:
@echo off
cd.>xxxx.txt
setlocal enabledelayedexpansion
for /f "delims=" %%i in ('findstr /i /v "p c -" test.txt') do (
set var=%%i
echo !var!>>xxxx.txt
)
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
FBOAR +2 2007-02-10 23:11
三人行,必有吾师焉。 学然后知不足,教然后知困,然后能自强也。
Floor 6 Posted 2007-02-10 22:54 ·  中国 北京 联通
银牌会员
★★★
努力做坏人
Credits 1,185
Posts 438
Joined 2006-08-28 12:00
19-year member
UID 61449
From 北京
Status Offline
```
@echo off&setlocal
for /f "delims=" %%i in ('findstr /r /i /v "^p ^c ^-" 1.txt') do echo %%i
pause
```
Recent Ratings for This Post ( 2 in total) Click for details
RaterScoreTime
ccwan +11 2007-02-10 23:19
FBOAR +2 2007-02-10 23:28
我今后在论坛的目标就是做个超级坏人!!!
Floor 7 Posted 2007-02-10 23:04 ·  中国 吉林 四平 联通
高级用户
★★★
Credits 859
Posts 413
Joined 2006-08-14 21:55
19-year member
UID 60532
Status Offline
When will the delay variable be useful?
Floor 8 Posted 2007-02-10 23:10 ·  中国 河北 廊坊 三河市 移动
金牌会员
★★★★
Credits 2,725
Posts 1,160
Joined 2006-09-23 12:00
19-year member
UID 63486
From 河北廊坊
Status Offline
三人行,必有吾师焉。 学然后知不足,教然后知困,然后能自强也。
Floor 9 Posted 2007-02-10 23:12 ·  中国 辽宁 大连 联通
初级用户
Credits 86
Posts 31
Joined 2007-01-09 13:30
19-year member
UID 75960
Gender Male
Status Offline
ccwan tested?
I haven't succeeded yet
xxxx.txt is blank
:(

[ Last edited by FBOAR on 2007-2-10 at 10:18 AM ]
Floor 10 Posted 2007-02-10 23:15 ·  中国 北京 联通
银牌会员
★★★
努力做坏人
Credits 1,185
Posts 438
Joined 2006-08-28 12:00
19-year member
UID 61449
From 北京
Status Offline
Alas for me, I don't know whether the LZ is filtering the lines containing the characters "p c -" or the lines at the beginning? The bright moonlight in front of the window....
我今后在论坛的目标就是做个超级坏人!!!
Floor 11 Posted 2007-02-10 23:17 ·  中国 辽宁 大连 联通
初级用户
Credits 86
Posts 31
Joined 2007-01-09 13:30
19-year member
UID 75960
Gender Male
Status Offline
Bro, it's starting with p c -
Floor 12 Posted 2007-02-10 23:20 ·  中国 河北 廊坊 三河市 移动
金牌会员
★★★★
Credits 2,725
Posts 1,160
Joined 2006-09-23 12:00
19-year member
UID 63486
From 河北廊坊
Status Offline
It's my misunderstanding. Only Brother 9527's code is correct. Hehe, but I'm both learning something and posting, so I'm not at a loss.
三人行,必有吾师焉。 学然后知不足,教然后知困,然后能自强也。
Floor 13 Posted 2007-02-10 23:24 ·  中国 河北 廊坊 三河市 移动
金牌会员
★★★★
Credits 2,725
Posts 1,160
Joined 2006-09-23 12:00
19-year member
UID 63486
From 河北廊坊
Status Offline
This time the code must be correct.
@ech off
for /f "delims==" %%i in ('findstr /b /i /v "pc -" test.txt') do @echo %%i
pause
三人行,必有吾师焉。 学然后知不足,教然后知困,然后能自强也。
Floor 14 Posted 2007-02-10 23:28 ·  中国 辽宁 大连 联通
初级用户
Credits 86
Posts 31
Joined 2007-01-09 13:30
19-year member
UID 75960
Gender Male
Status Offline
Got it. Used 9527, haha
Floor 15 Posted 2007-02-11 01:39 ·  中国 甘肃 兰州 电信
金牌会员
★★★★
Credits 4,103
Posts 1,744
Joined 2006-01-20 13:00
20-year member
UID 49241
Gender Male
From 甘肃.临泽
Status Offline
Directly modify the source file or use ssed? It's better to use ssed.
Forum Jump: