Re: "sort" problem

From: Naylor, Jim (Jnaylor_at_SCHNUCKS.COM)
Date: 02/26/04

  • Next message: cbaker_at_GOODYEAR.COM: "Re: "sort" problem"
    Date:         Thu, 26 Feb 2004 13:20:04 -0600
    To: aix-l@Princeton.EDU
    
    

    You could use this which specifies the field to sort on:

    sort -t. -k 2n,2 XX

    This defines a period as the field separator and tells it to sort on the
    second field

    Thanks,
    Jim Naylor
    Unix Systems Administrator
    Schnuck Markets, Inc.
    * Direct: (314) 994-4784
    *)) Cell: (314) 691-0186
    * Fax : (314) 994-4684
    * jnaylor@schnucks.com

    -----Original Message-----
    From: Denny Watkins [mailto:watkins@MORNINGSIDE.EDU]
    Sent: Thursday, February 26, 2004 12:50 PM
    To: aix-l@Princeton.EDU
    Subject: "sort" problem

    AIXers,

    Given a file "XX" whose contents are the following:
    219.144.82.44
    219.133.253.24
    219.133.146.220
    219.133.136.94
    219.133.65.24
    219.133.11.177

    I'm trying to sort "XX" so the results are as follows:
    219.133.11.177
    219.133.65.24
    219.133.136.94
    219.133.146.220
    219.133.253.24
    219.144.82.44

    I've tried the following sort :
    sort -u -d -t. +0 -n +1 -n +2 -n +3 -n XX

    But the results are as follows: (The 3rd column is out of order)
    219.133.11.177
    219.133.136.94
    219.133.146.220
    219.133.253.24
    219.133.65.24
    219.144.82.44

    When I do sort -u -d -t. +2 -n +3 -n XX (The 3rd & 4th columns are in
    order)
    I get the following:
    219.133.11.177
    219.133.65.24
    219.144.82.44
    219.133.136.94
    219.133.146.220
    219.133.253.24

    I've also tried the following which work OK on the column specified:
     sort -u -d -t. +3 -n XX
     sort -u -d -t. +2 -n XX
     sort -u -d -t. +1 -n XX

    What am I missing in the sort:
    sort -u -d -t. +0 -n +1 -n +2 -n +3 -n XX

    ?

    Thanks,
    Denny Watkins
    Director Computer Services
    Morningside College
    1501 Morningside Ave
    Sioux City, Ia 51106-1717
    Phone: 1-712-274-5250


  • Next message: cbaker_at_GOODYEAR.COM: "Re: "sort" problem"

    Relevant Pages

    • Re: How does the SORT statement work?
      ... What may be confusing you is that INPUT PROCEDURE and USING are *mutually ... exclusive* in the same SORT statement, as are OUTPUT PROCEDURE and GIVING. ... COLLATING SEQUENCE specifies the collating sequence by which the ...
      (comp.lang.cobol)
    • Re: Go Fish game in Lisp
      ... > actually whether the transitive property of < is satisfied? ... > If the sort function guarantees that it never compares ... But while CLHS specifies that SORT terminates, ...
      (comp.lang.lisp)
    • Re: BLOG mutter mutter computerised MOT
      ... If you look at your old certificate you will notice that it specifies ... I think this means I can no longer avoid the 'must sort that' pile, ...
      (uk.rec.motorcycles)
    • Re: Lisp vs. I/O
      ... I think IEEE-754 specifies the bit pattern. ... sort of thing with integers. ... Lisp can do all sorts of bit twiddling. ...
      (comp.lang.lisp)
    • Re: BTW
      ... Same sort of thing that specifies how much skin the ... actor/actress can show, how big the actor's or actress's name appears in the ...
      (rec.humor)