notepad++ delete duplicate and original lines to keep unique lines

天涯浪子 提交于 2019-12-18 09:52:09

问题


I have a text file with many duplicate lines and I am looking for a way to delete this duplicate and the original lines in notepad++, so that I can keep just the unique lines.

Or a way to mark all the unique lines. Or to mark all duplicates and originals to remove them manually.

The way is not that important, but at the result, I just need the unique lines.


回答1:


Assume your file is something like this

Then select the text and use TextFX Tools --> Sort lines case insensitive (at column). Make sure that you have Sort outputs only UNIQUE (at columns) line selected.




回答2:


I realize this is an older post and that you were looking for a notepad++ solution, but I came across this while searching for a solution for the same issue myself.

I ended up just using cygwin -- which I already had installed at the time-- and gnu tools.

uniq -u <sorted.file>

This only outputs the unique lines in the sorted.file file. Example:

# cat test.file
this is a dup line
this is also a dup line
this is a dup line
this is unique line 4
this is yet another dup
this is a dup line
this is also a dup line
this is unique line 1
this is unique line 3
this is also a dup line
this is yet another dup
this is unique line 2

Since the file is not sorted, I do so first:

# sort test.file | uniq -u
this is unique line 1
this is unique line 2
this is unique line 3
this is unique line 4


来源:https://stackoverflow.com/questions/29303148/notepad-delete-duplicate-and-original-lines-to-keep-unique-lines

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!