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

前端 未结 2 1999
囚心锁ツ
囚心锁ツ 2020-12-22 10:02

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 line

2条回答
  •  天涯浪人
    2020-12-22 10:28

    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 
    

    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
    

提交回复
热议问题