sort(1) sorting IP (v4) addresses (INET_ATON?)
Craig Leres
leres at ee.lbl.gov
Wed Nov 29 18:37:42 UTC 2017
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"
Craig
More information about the freebsd-hackers
mailing list