msgbartop
A cronological documentation test project, nothing serious, really!
msgbarbottom

12 Nov 07 Sort IP address

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

Tags: ,

Leave a Comment

You must be logged in to post a comment.