|
huzixuan
高级用户
   
积分 537
发帖 219
注册 2006-10-31 来自 芜湖
状态 离线
|
『第 16 楼』:
使用 LLM 解释/回答一下
for /f "delims=" %%i in (test.txt) do if not defined %%i set %%i=a&echo %%i
for /f "delims=" %%i in (test.txt) do if not defined %%i set %%i=a&echo %%i
|

江湖远
碧空长
路茫茫
一个人漫无目的的奔跑,风,刺骨的冷.... |
|
2007-4-21 07:37 |
|
|
everest79
金牌会员
      一叶枝头,万树皆春
积分 2564
发帖 1127
注册 2006-12-25
状态 离线
|
|
2007-4-21 10:05 |
|
|
waynebeat
初级用户
 
积分 84
发帖 28
注册 2006-5-3
状态 离线
|
|
2007-4-21 10:52 |
|
|
scriptor
银牌会员
    
积分 1187
发帖 555
注册 2006-12-21
状态 离线
|
『第 19 楼』:
使用 LLM 解释/回答一下
Originally posted by everest79 at 2007-4-21 04:41:
我的这个只能将重复的行删掉
a
a
b
c
d
a
b
c
d
并不能
a
a
b
c
d
b
c
d
src.txt是你原来的文本,执行完后dst.txt是过滤后的文本,将cmd切换到保存src.txt的目录下,再执行上边一行
哈哈....终于找到le
我就要的是这个啊
赞一个....
Originally posted by everest79 at 2007-4-21 04:41:
My this one can only delete the repeated lines
a
a
b
c
d
a
b
c
d
Cannot
a
a
b
c
d
b
c
d
src.txt is your original text, after execution, dst.txt is the filtered text. Switch the cmd to the directory where src.txt is saved, then execute the above line
Hahaha.... Finally found it
What I want is this
Give a thumbs up....
|
|
2007-9-26 14:20 |
|
|
chishingchan
银牌会员
    
积分 1282
发帖 538
注册 2002-11-2
状态 离线
|
『第 20 楼』:
使用 LLM 解释/回答一下
16楼的代码不行
D:\DOCUME~1\ADMINI~1>for /f "delims=" %i in (test.txt) do if not defined %i set
%i=a&echo %i
D:\DOCUME~1\ADMINI~1>if not defined aa set aa=a & echo aa
D:\DOCUME~1\ADMINI~1>if not defined bb set bb=a & echo bb
D:\DOCUME~1\ADMINI~1>if not defined cc set cc=a & echo cc
D:\DOCUME~1\ADMINI~1>if not defined dd set dd=a & echo dd
D:\DOCUME~1\ADMINI~1>if not defined bb set bb=a & echo bb
D:\DOCUME~1\ADMINI~1>if not defined cc set cc=a & echo cc
D:\DOCUME~1\ADMINI~1>if not defined ee set ee=a & echo ee
D:\DOCUME~1\ADMINI~1>
The code on floor 16 doesn't work
D:\DOCUME~1\ADMINI~1>for /f "delims=" %i in (test.txt) do if not defined %i set %i=a&echo %i
D:\DOCUME~1\ADMINI~1>if not defined aa set aa=a & echo aa
D:\DOCUME~1\ADMINI~1>if not defined bb set bb=a & echo bb
D:\DOCUME~1\ADMINI~1>if not defined cc set cc=a & echo cc
D:\DOCUME~1\ADMINI~1>if not defined dd set dd=a & echo dd
D:\DOCUME~1\ADMINI~1>if not defined bb set bb=a & echo bb
D:\DOCUME~1\ADMINI~1>if not defined cc set cc=a & echo cc
D:\DOCUME~1\ADMINI~1>if not defined ee set ee=a & echo ee
D:\DOCUME~1\ADMINI~1>
|
|
2007-9-26 22:22 |
|
|
yoyodos
初级用户
 
积分 128
发帖 59
注册 2007-9-15
状态 离线
|
『第 21 楼』:
使用 LLM 解释/回答一下
:)
@echo off
setlocal enabledelayedexpansion
cd.>temp.txt
for /f "tokens=* delims=:" %%i in ('findstr /n ".*" test.txt') do (
echo %%i>>temp.txt
)
for /f "tokens=1* delims=:" %%m in (temp.txt) do (
for /f "tokens=1* delims=:" %%x in ('findstr /v /c:"%%m:" temp.txt') do (
if "%%n"=="%%y" (
set str=%%y !str!
)
)
)
findstr /v "!str!" test.txt
pause
Last edited by yoyodos on 2007-9-26 at 11:28 PM ]
::)
@echo off
setlocal enabledelayedexpansion
cd.>temp.txt
for /f "tokens=* delims=:" %%i in ('findstr /n ".*" test.txt') do (
echo %%i>>temp.txt
)
for /f "tokens=1* delims=:" %%m in (temp.txt) do (
for /f "tokens=1* delims=:" %%x in ('findstr /v /c:"%%m:" temp.txt') do (
if "%%n"=="%%y" (
set str=%%y !str!
)
)
)
findstr /v "!str!" test.txt
pause
Last edited by yoyodos on 2007-9-26 at 11:28 PM ]
|
|
2007-9-26 23:26 |
|
|
terse
银牌会员
    
积分 2404
发帖 946
注册 2005-9-8
状态 离线
|
『第 22 楼』:
使用 LLM 解释/回答一下
Originally posted by chishingchan at 2007-9-26 22:22:
16楼的代码不行
D:\DOCUME~1\ADMINI~1>for /f "delims=" %i in (test.txt) do if not defined %i set
%i=a&echo %i
D:\DOCUME~1\ADMINI~1>if not defined aa set aa=a & ech ...
16楼的应该可以!
@echo off
for /f "delims=" %%i in (test.txt) do if not defined %%i set %%i=a&echo %%i>>test2.txt
pause
Originally posted by chishingchan at 2007-9-26 22:22:
The code on floor 16 doesn't work
D:\DOCUME~1\ADMINI~1>for /f "delims=" %i in (test.txt) do if not defined %i set
%i=a&echo %i
D:\DOCUME~1\ADMINI~1>if not defined aa set aa=a & ech ...
The one on floor 16 should be okay!
@echo off
for /f "delims=" %%i in (test.txt) do if not defined %%i set %%i=a&echo %%i>>test2.txt
pause
|
|
2007-9-26 23:52 |
|
|
bray
新手上路

积分 14
发帖 7
注册 2008-8-25
状态 离线
|
『第 23 楼』:
使用 LLM 解释/回答一下
Originally posted by huzixuan at 2007-4-21 07:37 AM:
for /f "delims=" %%i in (test.txt) do if not defined %%i set %%i=a&echo %%i
set %%i=a 有什么用处?
The sentence "set %%i=a" is used to set the variable represented by %%i to the value "a". In the context of this `for /f` loop, it's likely part of a process to initialize or assign a default value to each variable that is read from the `test.txt` file.
|
|
2008-8-28 17:42 |
|
|
bray
新手上路

积分 14
发帖 7
注册 2008-8-25
状态 离线
|
『第 24 楼』:
使用 LLM 解释/回答一下
Originally posted by bray at 2008-8-28 05:42 PM:
set %%i=a 有什么用处?
还有 如果只是想删除相邻重复行的内容怎么办
比如
aaa
aaa
bbb
aaa
aaa
aaa
ccc
ddd
ccc
要求处理后为:
aaa
bbb
aaa
ccc
ddd
ccc
Originally posted by bray at 2008-8-28 05:42 PM:
What is the use of `set %%i=a`?
Also, if you just want to delete adjacent duplicate lines, how to do it?
For example:
aaa
aaa
bbb
aaa
aaa
aaa
ccc
ddd
ccc
The desired result after processing is:
aaa
bbb
aaa
ccc
ddd
ccc
|
|
2008-8-28 18:05 |
|