[sort] Sort lines numerically with sort -n

Created on November 30, 2026

Use -n to compare lines by their numeric value.

printf '%s\n' 10 2 1 | sort -n
1
2
10

Plain text sorting would place 10 between 1 and 2. -n is short for --numeric-sort.

Reference

Shell command sort