Removing duplicate rows in vi?

后端 未结 14 2041
无人及你
无人及你 2021-01-29 23:10

I have a text file that contains a long list of entries (one on each line). Some of these are duplicates, and I would like to know if it is possible (and if so, how) to remove

14条回答
  •  北恋
    北恋 (楼主)
    2021-01-29 23:45

    I would combine two of the answers above:

    go to head of file
    sort the whole file
    remove duplicate entries with uniq
    
    1G
    !Gsort
    1G
    !Guniq
    

    If you were interested in seeing how many duplicate lines were removed, use control-G before and after to check on the number of lines present in your buffer.

提交回复
热议问题