From owner-freebsd-questions@FreeBSD.ORG Thu Apr 22 14:34:58 2004 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 01A2F16A4CF for ; Thu, 22 Apr 2004 14:34:58 -0700 (PDT) Received: from dan.emsphone.com (dan.emsphone.com [199.67.51.101]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8EB4343D48 for ; Thu, 22 Apr 2004 14:34:57 -0700 (PDT) (envelope-from dan@dan.emsphone.com) Received: (from dan@localhost) by dan.emsphone.com (8.12.10/8.12.10) id i3MLYjdx084851; Thu, 22 Apr 2004 16:34:45 -0500 (CDT) (envelope-from dan) Date: Thu, 22 Apr 2004 16:34:45 -0500 From: Dan Nelson To: JJB Message-ID: <20040422213441.GC4370@dan.emsphone.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-OS: FreeBSD 5.2-CURRENT X-message-flag: Outlook Error User-Agent: Mutt/1.5.6i cc: "freebsd-questions@FreeBSD. ORG" Subject: Re: Specifying sort fields X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 22 Apr 2004 21:34:58 -0000 In the last episode (Apr 22), JJB said: > How to specify the fields the sort program is to sort on? > > My file has blanks between the fields and I want to sort on > field number 9 which is ip address. > > I want to sort filea and put results in fileb. > > A sample of the sort command to be used from the command line would > go an long way to understanding how to use it. Somthing like "sort -k 9bn < filea > fileb" should work, but it will end up sorting only the first octect. If you can get your addresses to be 0-padded (000.000.000.000), you can drop the 'n' from the sort command and just do a plain ascii sort. -- Dan Nelson dnelson@allantgroup.com