sort(1) sorting IP (v4) addresses (INET_ATON?)
Rodney W. Grimes
freebsd-rwg at pdx.rh.CN85.dnsmgr.net
Wed Nov 29 19:11:24 UTC 2017
[ 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 at freebsd.org
More information about the freebsd-hackers
mailing list