Posted by Hans-Henry Jakobsen
Sorting IP addresses using sort is not easy because the dot confuses sort.
This line makes it possible to sort by the whole value of the address
sort -n -t . -k 1,1 -k 2,2 -k 3,3 -k 4,4 ipaddresses.txt
You can also sort by the last octet
sort -r. -n +3.0 ipaddresses.txt