Date: Wed, 29 Nov 2017 11:11:15 -0800 (PST) From: "Rodney W. Grimes" <freebsd-rwg@pdx.rh.CN85.dnsmgr.net> To: Craig Leres <leres@ee.lbl.gov> Cc: bsd-lists@BSDforge.com, FreeBSD Hackers <freebsd-hackers@freebsd.org> Subject: Re: sort(1) sorting IP (v4) addresses (INET_ATON?) Message-ID: <201711291911.vATJBFtk019974@pdx.rh.CN85.dnsmgr.net> In-Reply-To: <5bdff83a-52c2-ddfb-3d8a-9d260a6e62da@ee.lbl.gov>
next in thread | previous in thread | raw e-mail | index | archive | help
[ Charset UTF-8 unsupported, converting... ] > On 11/29/17 10:35, Chris H wrote: > > 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. > > % grep sortip ~/.cshrc > a sortip "sort -t. +0 -1n +1 -2n +2 -3n +3 -4n" Very nice, now I know why my attempt failed in the past, I had the n on the + arg, not n the - arg. -- Rod Grimes rgrimes@freebsd.org
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201711291911.vATJBFtk019974>