Date: Fri, 15 Jul 2005 00:10:58 +0200 From: Csaba Henk <csaba-ml@creo.hu> To: freebsd-questions@freebsd.org Subject: Re: using -t option with unix sort ? Message-ID: <20050714221058.GD45835@beastie.creo.hu> In-Reply-To: <42D6A546.6030308@malaby.com> References: <42D5C3FF.8070004@malaby.com> <7cbadc87050714023654bd3f26@mail.gmail.com> <7cbadc8705071402394bfd087b@mail.gmail.com> <42D6A546.6030308@malaby.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050714221058.GD45835>