Re: sorting IP addresses
Tim McNamara <[email protected]> Thu, 22 Dec 2011 14:48:36 +1300
| Newsgroups | gmane.org.user-groups.linux.new-zealand.general |
|---|---|
| Message-ID | <CA+YLJLuPzyQrr4umJ9aR8FuVbm8Ug18ZArPm64KEY7TLxD3hyg@mail.gmail.com> |
On 22 December 2011 14:46, Tim McNamara <[email protected]> wrote: > `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 [email protected] http://www.linux.net.nz/cgi-bin/mailman/listinfo/nzlug