From owner-freebsd-questions@FreeBSD.ORG Thu Jul 14 22:11:56 2005 Return-Path: X-Original-To: freebsd-questions@freebsd.org 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 35A2116A41C for ; Thu, 14 Jul 2005 22:11:56 +0000 (GMT) (envelope-from csaba@beastie.creo.hu) Received: from beastie.creo.hu (www.creo.hu [217.113.62.14]) by mx1.FreeBSD.org (Postfix) with ESMTP id 94AE743D46 for ; Thu, 14 Jul 2005 22:11:55 +0000 (GMT) (envelope-from csaba@beastie.creo.hu) Received: from beastie.creo.hu (localhost [127.0.0.1]) by beastie.creo.hu (8.13.3/8.13.3) with ESMTP id j6EMAwIE058686 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Fri, 15 Jul 2005 00:10:58 +0200 (CEST) (envelope-from csaba@beastie.creo.hu) Received: (from csaba@localhost) by beastie.creo.hu (8.13.3/8.13.3/Submit) id j6EMAw3r058685 for freebsd-questions@freebsd.org; Fri, 15 Jul 2005 00:10:58 +0200 (CEST) (envelope-from csaba) Date: Fri, 15 Jul 2005 00:10:58 +0200 From: Csaba Henk To: freebsd-questions@freebsd.org Message-ID: <20050714221058.GD45835@beastie.creo.hu> References: <42D5C3FF.8070004@malaby.com> <7cbadc87050714023654bd3f26@mail.gmail.com> <7cbadc8705071402394bfd087b@mail.gmail.com> <42D6A546.6030308@malaby.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <42D6A546.6030308@malaby.com> User-Agent: Mutt/1.5.9i Subject: Re: using -t option with unix sort ? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Jul 2005 22:11:56 -0000 On Thu, Jul 14, 2005 at 10:47:50AM -0700, Daniel Malaby wrote: > The sample data has 9 fields, I am trying to sort on the fifth field, > here is what I have tried. > > sort -t\t +4 -5 -o test.txt sample.txt > > I did try removing the space and it did not work, I have also tried > removing the -5. I think the spaces in the third field are confusing sort. Well, if you are willing to accept a non-orthodox solution, ruby -e 'puts $<.readlines.sort_by {|x| x.split(/\t/)[4]}' sample.txt > test.txt will do the job. I guess there should be a succint way of doing this with perl, too. Csaba