From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fcda7,3228891788e1919a X-Google-Attributes: gidfcda7,public X-Google-Thread: fee84,3228891788e1919a X-Google-Attributes: gidfee84,public From: stroyan@fc.hp.com (Mike Stroyan) Subject: Re: Sort keys buggy? Date: 1996/02/29 Message-ID: <4h32aj$kaf@fcnews.fc.hp.com>#1/1 X-Deja-AN: 141567483 references: <1996Feb28.190715.9327@llyene.jpl.nasa.gov> followup-to: comp.sys.hp.hpux,comp.unix.osf.osf1 organization: Hewlett-Packard Fort Collins Site newsgroups: comp.sys.hp.hpux,comp.unix.osf.osf1 Michael P Urban (urban@cobra.jpl.nasa.gov) wrote: |The output of the command, | sort -k 1 -k 2n |with an input file like: ... |b 2 ... |b 10 |b 20 ... |does not produce the result I would expect; the second column is |sorted lexicographically instead of numerically. This occurs on HP-UX |9.01, HP-UX 10, and DEC OSF1 V3.2. The trick is that the first key, "-k 1", is specifying a range from the start of the first field to the end of line. All of the lines are unique in that key, so the second key never gets a chance to influence the sort. You can get the effect you were looking for by using a first key that is only the first field- sort -k 1,1 -k 2n -- Mike Stroyan, mike_stroyan@fc.hp.com