CMD Master
Back to Blog
Arnošt Havelka

SORT - Unique Lines

Sort and remove duplicates.

Start Interactive Lesson
SORT - Unique Lines

Remove duplicates while sorting your data.

The -u Flag

The -u (unique) flag tells sort to suppress all but one in each set of lines that sort equally.

Try the command

Filter out duplicates!

Build the command
sort-u ips.txt
Terminal
~$sort -u ips.txt
10.0.0.1 10.0.0.2

References

These documentation links provide authoritative details for the commands used in this article.

Up Next

Chain grep, sort, and wc in one command

Count matching lines and filter a sorted list by combining cat, grep, sort, and wc.