From owner-freebsd-hackers@freebsd.org Wed Nov 29 19:11:24 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 A964ADB9558 for ; Wed, 29 Nov 2017 19:11:24 +0000 (UTC) (envelope-from freebsd-rwg@pdx.rh.CN85.dnsmgr.net) Received: from pdx.rh.CN85.dnsmgr.net (br1.CN84in.dnsmgr.net [69.59.192.140]) (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 7FB671A0E for ; Wed, 29 Nov 2017 19:11:24 +0000 (UTC) (envelope-from freebsd-rwg@pdx.rh.CN85.dnsmgr.net) Received: from pdx.rh.CN85.dnsmgr.net (localhost [127.0.0.1]) by pdx.rh.CN85.dnsmgr.net (8.13.3/8.13.3) with ESMTP id vATJBFd8019975; Wed, 29 Nov 2017 11:11:15 -0800 (PST) (envelope-from freebsd-rwg@pdx.rh.CN85.dnsmgr.net) Received: (from freebsd-rwg@localhost) by pdx.rh.CN85.dnsmgr.net (8.13.3/8.13.3/Submit) id vATJBFtk019974; Wed, 29 Nov 2017 11:11:15 -0800 (PST) (envelope-from freebsd-rwg) From: "Rodney W. Grimes" Message-Id: <201711291911.vATJBFtk019974@pdx.rh.CN85.dnsmgr.net> Subject: Re: sort(1) sorting IP (v4) addresses (INET_ATON?) In-Reply-To: <5bdff83a-52c2-ddfb-3d8a-9d260a6e62da@ee.lbl.gov> To: Craig Leres Date: Wed, 29 Nov 2017 11:11:15 -0800 (PST) CC: bsd-lists@BSDforge.com, FreeBSD Hackers X-Mailer: ELM [version 2.4ME+ PL121h (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-Mailman-Approved-At: Wed, 29 Nov 2017 20:28:53 +0000 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 19:11:24 -0000 [ 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