Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 29 Nov 2017 10:35:48 -0800
From:      "Chris H" <bsd-lists@BSDforge.com>
To:        "FreeBSD Hackers" <freebsd-hackers@freebsd.org>
Subject:   sort(1) sorting IP (v4) addresses (INET_ATON?)
Message-ID:  <1f2d985d685f66ad01ff2810cbb941c9@udns.ultimatedns.net>

index | next in thread | raw e-mail

I'm constantly dealing with IPv4 addresses (millions). Sorting the mass
is never perfect, and I'm forced to *visually* fix those out of order.
Yet I continue to (later) find some I've missed -- I'm sick of it!
Thus far, I've found I attain the best results with sort(1):

sort -t . -k 4,4n -k 3,3n -k 2,2n  ./TCPLIST | sort -g>./SORTED

Which ends up pretty damn close. But not perfect. :(
Then it occurred to me that adding INET_ATON to sort, allowing for
an additional -inet option to sort(1) for IP addresses -- hell if
MySQL can provide it[1], why the heck can't sort(1)?
Else I guess I'll have to try and give a shot at cobbling up a C
utility to manage it. But seems like too much work for something
that'll only accomplish one thing. :(

Thanks for any thoughts, or further insight.

[1] https://dev.mysql.com/doc/refman/5.7/en/miscellaneous-functions.html#function_inet-aton

--Chris




help

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1f2d985d685f66ad01ff2810cbb941c9>