中国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-24 17:20
47,812 topics / 349,917 posts / today 0 new / 48,274 members
DOS批处理 & 脚本技术(批处理室) » I want to delete the lines starting with p, c, - in the txt...
Printable Version  2,672 / 17
Floor1 FBOAR Posted 2007-02-10 21:49
初级用户 Posts 31 Credits 86
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 ]
Floor2 ccwan Posted 2007-02-10 22:08
金牌会员 Posts 1,160 Credits 2,725 From 河北廊坊
@ech oof

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

pause
Floor3 ccwan Posted 2007-02-10 22:10
金牌会员 Posts 1,160 Credits 2,725 From 河北廊坊
ororjustsimplynotuseeol

@echo off

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

pause
Floor4 FBOAR Posted 2007-02-10 22:43
初级用户 Posts 31 Credits 86
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
Floor5 ccwan Posted 2007-02-10 22:51
金牌会员 Posts 1,160 Credits 2,725 From 河北廊坊
Don't understand why you need to enable variable delay?




If you must use variable delay, the code is as follows:
Floor6 9527 Posted 2007-02-10 22:54
银牌会员 Posts 438 Credits 1,185 From 北京
```
@echo off&setlocal
for /f "delims=" %%i in ('findstr /r /i /v "^p ^c ^-" 1.txt') do echo %%i
pause
```
Floor7 anqing Posted 2007-02-10 23:04
高级用户 Posts 413 Credits 859
When will the delay variable be useful?
Floor8 ccwan Posted 2007-02-10 23:10
金牌会员 Posts 1,160 Credits 2,725 From 河北廊坊
Floor9 FBOAR Posted 2007-02-10 23:12
初级用户 Posts 31 Credits 86
ccwan tested?
I haven't succeeded yet
xxxx.txt is blank
:(

[ Last edited by FBOAR on 2007-2-10 at 10:18 AM ]
Floor10 9527 Posted 2007-02-10 23:15
银牌会员 Posts 438 Credits 1,185 From 北京
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....
Floor11 FBOAR Posted 2007-02-10 23:17
初级用户 Posts 31 Credits 86
Bro, it's starting with p c -
Floor12 ccwan Posted 2007-02-10 23:20
金牌会员 Posts 1,160 Credits 2,725 From 河北廊坊
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.
Floor13 ccwan Posted 2007-02-10 23:24
金牌会员 Posts 1,160 Credits 2,725 From 河北廊坊
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
Floor14 FBOAR Posted 2007-02-10 23:28
初级用户 Posts 31 Credits 86
Got it. Used 9527, haha
Floor15 vkill Posted 2007-02-11 01:39
金牌会员 Posts 1,744 Credits 4,103 From 甘肃.临泽
Directly modify the source file or use ssed? It's better to use ssed.
1 2  Next
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023