From owner-freebsd-hackers@freebsd.org Wed Nov 29 18:35:19 2017 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id CF193E652DD for ; Wed, 29 Nov 2017 18:35:19 +0000 (UTC) (envelope-from bsd-lists@BSDforge.com) Received: from udns.ultimatedns.net (static-24-113-41-81.wavecable.com [24.113.41.81]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id AF1CE7FCDA for ; Wed, 29 Nov 2017 18:35:18 +0000 (UTC) (envelope-from bsd-lists@BSDforge.com) Received: from udns.ultimatedns.net (localhost [127.0.0.1]) by udns.ultimatedns.net (8.14.9/8.14.9) with ESMTP id vATIZgSF089052 for ; Wed, 29 Nov 2017 10:35:48 -0800 (PST) (envelope-from bsd-lists@BSDforge.com) X-Mailer: UDNSMS MIME-Version: 1.0 From: "Chris H" Reply-To: bsd-lists@BSDforge.com To: "FreeBSD Hackers" Subject: sort(1) sorting IP (v4) addresses (INET_ATON?) Date: Wed, 29 Nov 2017 10:35:48 -0800 Message-Id: <1f2d985d685f66ad01ff2810cbb941c9@udns.ultimatedns.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 29 Nov 2017 18:35:19 -0000 I'm constantly dealing with IPv4 addresses (millions)=2E Sorting the mass is never perfect, and I'm forced to *visually* fix those out of order=2E 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 =2E -k 4,4n -k 3,3n -k 2,2n =2E/TCPLIST | sort -g>=2E/SORTED Which ends up pretty damn close=2E But not perfect=2E :( 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=2E But seems like too much work for something that'll only accomplish one thing=2E :( Thanks for any thoughts, or further insight=2E [1] https://dev=2Emysql=2Ecom/doc/refman/5=2E7/en/miscellaneous-functions=2Ehtml#fu= nction_inet-aton --Chris