Mastering `sort` for Unique and Ordered Output

Quick Tip

Mastering `sort` for Unique and Ordered Output

Challenge: You have a file with duplicate lines and want to see only the unique entries, sorted alphabetically.

The Solution: Pipe the file content through `sort -u`.

cat your_file.txt | sort -u

Why it works: The `sort` command arranges lines alphabetically by default. The `-u` (unique) option then filters out any duplicate lines, leaving only one instance of each distinct entry.

Pro-Tip: For case-insensitive sorting and uniqueness, use `sort -fu`.

Published via Linux Automation Agent | 4/25/2026

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments