|
yohaa
新手上路

积分 10
发帖 4
注册 2007-4-21
状态 离线
|
『楼 主』:
请问如何用批处理删掉所有重复行!
使用 LLM 解释/回答一下
请问有没有人知道怎样删掉文本文件中的所有的重复行,只留下非重行,例如:
一个文本文件中含有下面几行:
a
a
b
c
d
现在我相删掉重复的a, 只留下没有重复的b c d, 用批处理能做到么?
谢谢大家啦!
Is there anyone who knows how to delete all duplicate lines in a text file and leave only non-duplicate lines? For example:
A text file contains the following lines:
a
a
b
c
d
Now I want to delete the duplicate a and leave only the non-duplicate b c d. Can this be done with a batch script?
Thank you everyone!
|
|
2007-4-21 02:26 |
|
|
everest79
金牌会员
      一叶枝头,万树皆春
积分 2564
发帖 1127
注册 2006-12-25
状态 离线
|
『第 2 楼』:
使用 LLM 解释/回答一下
cd.>dst.txt&&for /f "delims=" %i in (src.txt) do findstr /b /e "%i" dst.txt||echo %i>>dst.txt
cd.>dst.txt&&for /f "delims=" %i in (src.txt) do findstr /b /e "%i" dst.txt||echo %i>>dst.txt
|
|
2007-4-21 02:32 |
|
|
flyinspace
银牌会员
    
积分 1206
发帖 517
注册 2007-3-25
状态 离线
|
『第 3 楼』:
使用 LLM 解释/回答一下
cd.>dst.txt
这句话有什么用呢???
What is the use of this sentence "cd.>dst.txt"?
|

知,不觉多。不知,乃求知 |
|
2007-4-21 03:55 |
|
|
everest79
金牌会员
      一叶枝头,万树皆春
积分 2564
发帖 1127
注册 2006-12-25
状态 离线
|
『第 4 楼』:
使用 LLM 解释/回答一下
我是怕find过程中,第一次会不能正常执行
I am worried that the first time during the find process may not execute normally
|
|
2007-4-21 04:09 |
|
|
flyinspace
银牌会员
    
积分 1206
发帖 517
注册 2007-3-25
状态 离线
|
『第 5 楼』:
使用 LLM 解释/回答一下
嗯,那我明白了。。
Um, then I understand..
|

知,不觉多。不知,乃求知 |
|
2007-4-21 04:20 |
|
|
everest79
金牌会员
      一叶枝头,万树皆春
积分 2564
发帖 1127
注册 2006-12-25
状态 离线
|
『第 6 楼』:
使用 LLM 解释/回答一下
其实也没达到楼主要求,我这会才看明白楼主要求什么
Actually, it didn't meet the owner's requirement. I just understand what the owner's requirement is at this moment
|
|
2007-4-21 04:28 |
|
|
flyinspace
银牌会员
    
积分 1206
发帖 517
注册 2007-3-25
状态 离线
|
『第 7 楼』:
使用 LLM 解释/回答一下
呵呵,这个用两个for循环是最好的处理方式了。
Hehe, using two for loops is the best way to handle this.
|

知,不觉多。不知,乃求知 |
|
2007-4-21 04:31 |
|
|
everest79
金牌会员
      一叶枝头,万树皆春
积分 2564
发帖 1127
注册 2006-12-25
状态 离线
|
『第 8 楼』:
使用 LLM 解释/回答一下
楼主要将重复的行全删掉,一个也不保留
The building owner wants to delete all duplicate lines, not keep any.
|
|
2007-4-21 04:35 |
|
|
yohaa
新手上路

积分 10
发帖 4
注册 2007-4-21
状态 离线
|
『第 9 楼』:
使用 LLM 解释/回答一下
请问兄台,怎么个用法呢,为了这个问题,我这两天头都搞大啦,
Excuse me, how to use it? For this problem, my head has been messed up these two days.
|
|
2007-4-21 04:38 |
|
|
yohaa
新手上路

积分 10
发帖 4
注册 2007-4-21
状态 离线
|
『第 10 楼』:
使用 LLM 解释/回答一下
『第 9 楼』:
请问7楼兄台,怎么个用法呢,为了这个问题,我这两天头都搞大啦, 另外谢谢everest79
的热情帮忙!
『Building 9』:
Excuse me, brother on floor 7, how to use it? For this problem, my head has been messed up these two days, and also thank everest79 for the enthusiastic help!
|
|
2007-4-21 04:40 |
|
|
everest79
金牌会员
      一叶枝头,万树皆春
积分 2564
发帖 1127
注册 2006-12-25
状态 离线
|
『第 11 楼』:
使用 LLM 解释/回答一下
我的这个只能将重复的行删掉
a
a
b
c
d
a
b
c
d
并不能
a
a
b
c
d
b
c
d
src.txt是你原来的文本,执行完后dst.txt是过滤后的文本,将cmd切换到保存src.txt的目录下,再执行上边一行
My this can only delete the repeated lines
a
a
b
c
d
a
b
c
d
can't
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
|
|
2007-4-21 04:41 |
|
|
NaturalJ0
银牌会员
    
积分 1181
发帖 533
注册 2006-8-14
状态 离线
|
『第 12 楼』:
使用 LLM 解释/回答一下
namejm 版主以前写过一个完全符合楼主要求的代码,搜下吧。
版主以前写过一个完全符合楼主要求的代码,搜下吧。
The moderator namejm once wrote a code that completely meets the requirements of the post, just search for it.
|
|
2007-4-21 04:42 |
|
|
yohaa
新手上路

积分 10
发帖 4
注册 2007-4-21
状态 离线
|
『第 13 楼』:
使用 LLM 解释/回答一下
另外运行了二楼兄弟的命令,也像一个重复的也删不了,运行完了还是
a
a
b
c
d
In addition, I ran the command from the brother on the second floor, and it was also a duplicate and couldn't be deleted. After running, it was still
a
a
b
c
d
|
|
2007-4-21 04:51 |
|
|
everest79
金牌会员
      一叶枝头,万树皆春
积分 2564
发帖 1127
注册 2006-12-25
状态 离线
|
『第 14 楼』:
使用 LLM 解释/回答一下
仔细想想,我试了,没问题,你看那做错没有
Think carefully, I tried it, it's okay, let's see if there's any mistake.
|
|
2007-4-21 04:59 |
|
|
flyinspace
银牌会员
    
积分 1206
发帖 517
注册 2007-3-25
状态 离线
|
『第 15 楼』:
使用 LLM 解释/回答一下
那定义一个.ini文件就可以达到要求了。。
.ini 里是删除的东西。。
然后依然是两个for循环。
Then defining an .ini file can meet the requirement.
The .ini file contains the things to be deleted.
Then there are still two for loops.
|

知,不觉多。不知,乃求知 |
|
2007-4-21 06:28 |
|