Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!convex!felps From: felps@convex.com (Robert Felps) Newsgroups: comp.unix.questions Subject: Re: sort first two fields in numeric order Keywords: this shouldn't be difficult Message-ID: Date: 19 Jun 91 11:49:37 GMT References: <1991Jun18.222520.7816@drd.com> Sender: usenet@convex.com (news access account) Distribution: na Organization: CONVEX Computer Corporation, Richardson, Tx., USA Lines: 50 Nntp-Posting-Host: mikey.convex.com In <1991Jun18.222520.7816@drd.com> mark@drd.com (Mark Lawrence) writes: >I've got a file with tab separated columns of stuff that I >expand to pretty tabstops and sort. I want to sort the file >primarily on the first column and then on the second, both >numerically. No problem, right? >expand -5 foo | sort +0n -1n >should treat both the first and second columns as numerics >and sort them in that order. It don't. I get: >16 0 >16 1 >16 10 >16 19 >16 2 >16 21 >I'm missing something terribly obvious here. Comments? Well, obvious, probably not terribly though. Try, expand -5 foo | sort +0n +1n or expand -5 foo | sort +0n -1n +1n -2n From the sort man page: The notation +pos1 -pos2 restricts a sort key to a field beginning at pos1 and ending just before pos2. ^^^^^^^^^^^^^^^^^^^^^^^ The +Col +Col format, as in example 1, doesn't provide an ending column because it is not necessary. As the SYNOPSIS line shows if pos1 is specified pos2 is optional. sort [ -mubdfinrctx ] [ +pos1 [ -pos2 ] ] ... [ -o name ] [ -T directory ] [ name ] ... >-- >mark@drd.com >mark@jnoc.go.jp $B!J%^!<%/!&%i%l%s%9!K(B Nihil novum sub solem Hope this helps, Robert Felps I do not speak for felps@convex.com Convex Computer Corp Convex and I seldom Product Specialist 3000 Waterview Parkway speak for myself. Tech. Assistant Ctr Richardson, Tx. 75080 VMS? What's that? 1(800) 952-0379