Date: Wed, 29 Nov 2017 20:31:24 +0000 From: Andrew Duane <aduane@juniper.net> To: "Rodney W. Grimes" <freebsd-rwg@pdx.rh.CN85.dnsmgr.net>, "bsd-lists@BSDforge.com" <bsd-lists@BSDforge.com> Cc: FreeBSD Hackers <freebsd-hackers@freebsd.org> Subject: RE: sort(1) sorting IP (v4) addresses (INET_ATON?) Message-ID: <SN1PR0501MB2125BD17CAD557D189339DB5CE3B0@SN1PR0501MB2125.namprd05.prod.outlook.com> In-Reply-To: <201711291909.vATJ9eir019941@pdx.rh.CN85.dnsmgr.net> References: <1f2d985d685f66ad01ff2810cbb941c9@udns.ultimatedns.net> <201711291909.vATJ9eir019941@pdx.rh.CN85.dnsmgr.net>
next in thread | previous in thread | raw e-mail | index | archive | help
> From: owner-freebsd-hackers@freebsd.org [mailto:owner-freebsd- > hackers@freebsd.org] On Behalf Of Rodney W. Grimes > Sent: Wednesday, November 29, 2017 2:10 PM > To: bsd-lists@BSDforge.com > Cc: FreeBSD Hackers <freebsd-hackers@freebsd.org> > Subject: Re: sort(1) sorting IP (v4) addresses (INET_ATON?) >=20 > > I'm constantly dealing with IPv4 addresses (millions). Sorting the > > mass is never perfect, and I'm forced to *visually* fix those out of or= der. > > 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. > > The old school on this is you do a substitue of the . for a <sp> and then= just > use sort -n on that then munge it back to have the .'s, >=20 > Though I would not be opposed to sort learning about inet numbers, it > should not be -inet as you would want to be able to apply this to fields = as in 4i > to sort the 4th field as an inet number. > Actually I guess you need both to be orthagnal with -n and others. > -- > Rod Grimes rgrimes@freebs= d.org Let's not forget that pesky other format: IPv6. Do we need a capital 'I' fo= r that? BTW, would using i/I as the format specifier conflict with '-i' for "ignore= -case"? .................................... Andrew L. Duane - Principal Resident Engineer Juniper Networks, Inc. aduane@juniper.net
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?SN1PR0501MB2125BD17CAD557D189339DB5CE3B0>