Removing duplicate rows in vi?

Sydius picture Sydius · Dec 8, 2008 · Viewed 72.2k times · Source

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 any duplicates. I am interested in doing this from within vi/vim, if possible.

Answer

Brian Carper picture Brian Carper · Dec 8, 2008

If you're OK with sorting your file, you can use:

:sort u