A chronological documentation test project, nothing serious, really!

12 Nov 2007 Sort IP address

Posted by

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

Tags: ,

Comments are closed.