Discussion:
sorting IP addresses
Tim McNamara
2011-12-22 01:46:29 UTC
Permalink
`sort -n` does a good job with most numbers, but is imprecise with IP4
addresses because they're apparently tokenized by the first
non-numeric character.

How would I recursively sort through all four fields of a form nnn.nnn.nnn.nnn?

_______________________________________________
NZLUG mailing list ***@linux.net.nz
http://www.linux.net.nz/cgi-bin/mailman/listinfo/nzlug
Tim McNamara
2011-12-22 01:48:36 UTC
Permalink
Post by Tim McNamara
`sort -n` does a good job with most numbers, but is imprecise with IP4
addresses because they're apparently tokenized by the first
non-numeric character.
How would I recursively sort through all four fields of a form nnn.nnn.nnn.nnn?
Sorry, forgot to engage 'use a search engine for search' mentality.
Answer found[0]:

sort -n -t . -k 1,1 -k 2,2 -k 3,3 -k 4,4

[0]: http://www.madboa.com/geek/sort-addr/

_______________________________________________
NZLUG mailing list ***@linux.net.nz
http://www.linux.net.nz/cgi-bin/mailman/listinfo/nzlug

Loading...