[sort] Sort lines and keep only one of each

Created on November 30, 2026

Use sort -u to sort lines and collapse equal entries to one.

printf 'orange\napple\norange\nbanana\napple\n' | sort -u
apple
banana
orange

-u is short for --unique. The output follows the sort order, so the input's original order is lost.

Reference

Shell command sort