From owner-freebsd-hackers@freebsd.org Wed Nov 29 20:31:36 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 05ECBDBB256 for ; Wed, 29 Nov 2017 20:31:36 +0000 (UTC) (envelope-from aduane@juniper.net) Received: from mx0b-00273201.pphosted.com (mx0b-00273201.pphosted.com [67.231.152.164]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "*.pphosted.com", Issuer "thawte SHA256 SSL CA" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id A591A63694 for ; Wed, 29 Nov 2017 20:31:35 +0000 (UTC) (envelope-from aduane@juniper.net) Received: from pps.filterd (m0108163.ppops.net [127.0.0.1]) by mx0b-00273201.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id vATKU8OK023169; Wed, 29 Nov 2017 12:31:26 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=juniper.net; h=from : to : cc : subject : date : message-id : references : in-reply-to : content-type : content-transfer-encoding : mime-version; s=PPS1017; bh=gIfdhOxvMF6XyaHBWZUFNhctagO+pwxwUtMk/Q4AnRY=; b=bjEdjWwMOxMpYvW0K3VBBKZOEzTvN+qtbgfXyu3yS2GFT+Td0nCyodWHGe3ooxkfJj+h PCa326jFOQSdiQ58ltSkkLiWQlRKwIMXq5qx+8BrOAXJ1bBbbwO18n3RlxUjqS7vWq/d pBmtg0wCxp463Bj6Zdw4P8eMDrUfxdsf4gNpbmNmPMU6mGaL3bRMwBfC8hxlD7QyaQy2 bm8SD6NGYFUcoYDwp0MkwqLoJVut1ZRV9GubIry+3640h+wg4avpJzhpOc1tKUxtza3C hhw1YTlzD+8Pd6YvBbX/5zOE9NuQUq/xyu6deX4C5WBk2llIiYdB5ioQwkfEtzwa5eu9 4Q== Received: from nam02-bl2-obe.outbound.protection.outlook.com (mail-bl2nam02lp0083.outbound.protection.outlook.com [207.46.163.83]) by mx0b-00273201.pphosted.com with ESMTP id 2ej3r8g14f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Wed, 29 Nov 2017 12:31:25 -0800 Received: from SN1PR0501MB2125.namprd05.prod.outlook.com (10.163.228.152) by SN1PR0501MB2127.namprd05.prod.outlook.com (10.163.228.154) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.282.3; Wed, 29 Nov 2017 20:31:24 +0000 Received: from SN1PR0501MB2125.namprd05.prod.outlook.com ([10.163.228.152]) by SN1PR0501MB2125.namprd05.prod.outlook.com ([10.163.228.152]) with mapi id 15.20.0282.006; Wed, 29 Nov 2017 20:31:24 +0000 From: Andrew Duane To: "Rodney W. Grimes" , "bsd-lists@BSDforge.com" CC: FreeBSD Hackers Subject: RE: sort(1) sorting IP (v4) addresses (INET_ATON?) Thread-Topic: sort(1) sorting IP (v4) addresses (INET_ATON?) Thread-Index: AQHTaUDTUa1XIgiacUqCUAfLVHa5BKMruLQAgAAVwcA= Date: Wed, 29 Nov 2017 20:31:24 +0000 Message-ID: References: <1f2d985d685f66ad01ff2810cbb941c9@udns.ultimatedns.net> <201711291909.vATJ9eir019941@pdx.rh.CN85.dnsmgr.net> In-Reply-To: <201711291909.vATJ9eir019941@pdx.rh.CN85.dnsmgr.net> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [66.129.241.13] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; SN1PR0501MB2127; 6:EEyLtfurgQV+T1CqHleXzhWWQeFP2ok/KwJ7eYN/vXzcOgPtgivaxnn931ujXJ+PeZbnPi5TnveVj5wi0LdkhAfgOlfWTKdNbiNELZwzKN+9i+Jsu2o5FtKJvQWBe5AF3egRfDrn8LpXo12gHJjC0mIds94dv3FMhFg1oKzqLZtEPSn60dH+/nT45xg912lTlaYvkzutBf6W9JjcBoBu90nZSJURaa7ekgztzeqMSa2EPpHRQIiEYBpjgwkCRjQydi43eJE8RsqBvWRpLJeY7bZBYhMzGJ4SdjPF+0y5C0mwS39RA8XXXv/MgwL388I/clel+X5SnjOLTv2pa0kdkkYUa7OEw6Am2jhrGLgi+eU=; 5:7stcxNqn7Eq23B3PN2DHVGSeb52GbZsFTMfVt8YTlhNNvsfJEXZotU7ul2fqDFzcGNstLIplEDxolE7x4VeaJ60qqM+V7tZrBxgXmATqiH+2nyBS+/7/uukcDVZ/SWwUemV7jml1PImKXwxMoSZjCweAWzOlJ8iL2KGo4irweBs=; 24:M+dtcrIPSc2syN3x2TfJiczdyv57LYTeI6mWB2oru0+NcMQTh5D49ABwXh4v3sQ0U3ZNlI1GH2AormkerZv7dMwIpgWCZ+gz39Ll6kLsdZY=; 7:CHhaRfSHjxvJ0rhZCswv8exoofdq3yMhR3zm5Rsezw8hzx/3oXVmv9CUQXwy7c3gxdiKSEz+i5ivikZlZHaU+6sxh6cr076y8qY1F1IZSGpSXCunY5r7FC1k4Lz1FQ57dmuK0iUPcQpDcz/dEVYmgcb5A73uTClp1rV8VI7mSKAb9Lnk5cShq0uAeaeH3nUi5/0jLbP/6URDPq26FdxDrJz5udgihvLY21+uIwV4W4t4H8Ocfj4azKFB8LqvCbxI x-ms-exchange-antispam-srfa-diagnostics: SSOS; x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: d445d654-94f6-4126-5e47-08d5376828cf x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(48565401081)(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(5600026)(4604075)(2017052603199); SRVR:SN1PR0501MB2127; x-ms-traffictypediagnostic: SN1PR0501MB2127: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(138986009662008); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(6040450)(2401047)(8121501046)(5005006)(3002001)(93006095)(93001095)(3231022)(10201501046)(6055026)(6041248)(20161123558100)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123560025)(20161123564025)(20161123555025)(20161123562025)(6072148)(201708071742011); SRVR:SN1PR0501MB2127; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:SN1PR0501MB2127; x-forefront-prvs: 05066DEDBB x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(6009001)(346002)(376002)(366004)(39860400002)(199003)(189002)(57704003)(2950100002)(7696005)(53936002)(105586002)(106356001)(68736007)(6116002)(5660300001)(102836003)(3846002)(9686003)(101416001)(14454004)(478600001)(2501003)(76176010)(54356010)(50986010)(99286004)(97736004)(53546010)(66066001)(86362001)(6506006)(33656002)(110136005)(189998001)(316002)(55016002)(25786009)(4326008)(6246003)(77096006)(229853002)(74316002)(2906002)(3660700001)(7736002)(3280700002)(6436002)(305945005)(81156014)(81166006)(8936002)(2900100001)(8676002); DIR:OUT; SFP:1102; SCL:1; SRVR:SN1PR0501MB2127; H:SN1PR0501MB2125.namprd05.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; received-spf: None (protection.outlook.com: juniper.net does not designate permitted sender hosts) x-microsoft-antispam-message-info: 1c0DTzF/ck51A38xjmia0p3PrLTqQndl3y+I1hL/T1F2JyODhhV+D+8W2AosmWk6pSlxkVWNN3thCFPKjJwiqA== spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: juniper.net X-MS-Exchange-CrossTenant-Network-Message-Id: d445d654-94f6-4126-5e47-08d5376828cf X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Nov 2017 20:31:24.2192 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: bea78b3c-4cdb-4130-854a-1d193232e5f4 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR0501MB2127 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-11-29_07:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_spam_notspam policy=outbound_spam score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1711290265 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 20:31:36 -0000 > From: owner-freebsd-hackers@freebsd.org [mailto:owner-freebsd- > hackers@freebsd.org] On Behalf Of Rodney W. Grimes > Sent: Wednesday, November 29, 2017 2:10 PM > To: bsd-lists@BSDforge.com > Cc: FreeBSD Hackers > Subject: Re: sort(1) sorting IP (v4) addresses (INET_ATON?) >=20 > > I'm constantly dealing with IPv4 addresses (millions). Sorting the > > mass is never perfect, and I'm forced to *visually* fix those out of or= der. > > 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. :( 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. But seems like too much work for something > > that'll only accomplish one thing. :( > > > > Thanks for any thoughts, or further insight. > > The old school on this is you do a substitue of the . for a and then= just > use sort -n on that then munge it back to have the .'s, >=20 > Though I would not be opposed to sort learning about inet numbers, it > should not be -inet as you would want to be able to apply this to fields = as in 4i > to sort the 4th field as an inet number. > Actually I guess you need both to be orthagnal with -n and others. > -- > Rod Grimes rgrimes@freebs= d.org Let's not forget that pesky other format: IPv6. Do we need a capital 'I' fo= r that? BTW, would using i/I as the format specifier conflict with '-i' for "ignore= -case"? .................................... Andrew L. Duane - Principal Resident Engineer Juniper Networks, Inc. aduane@juniper.net