[Linux] Remove Duplicate Lines by Piping sort and uniq

Tadashi Shigeoka ·  Thu, July 12, 2012

I wanted to remove duplicates from a list of email addresses and considered several approaches for the easiest method. Using Linux commands seemed most convenient, so I removed duplicate lines by piping sort and uniq.

Linux

Example Command to Sort and Remove Duplicate Lines

$ sort original.txt | uniq > sorted_unique.txt

For simple tasks like this, using Linux commands is easier than using Excel or writing a bit of code in a programming language.

That’s all from the Gemba where I wanted to quickly remove duplicate lines.

That’s all from the Gemba.