IZ49161: SORT COMMAND DOCUMENTATION NEEDS CLARITY.

Subscribe

You can track all active APARs for this component.

APAR status

  • Closed as documentation error.

Error description

  • The sort command and its documentation manual do not
    match.   Customer is using the following syntax
    "-b -k3.6,3n" and the result does not correspond with
    the manual pages.
    
    Here are the samples:
    
    Example 1:
    $ cat /tmp/sortdsk1
    x x hdisk1
    x x  hdisk10
    x x hdisk100
    y y hdisk2
    y y  hdisk20
    y y hdisk200
     $
    
     $ sort -k3.6,3n /tmp/sortdsk1
    x x  hdisk10
    x x hdisk1
    x x hdisk100
    y y  hdisk20
    y y hdisk2
    y y hdisk200
     $
    
    The sort result above is difficult to explain until one
    realizes that the same result is achieved by sorting
    without any key:
    
     $ sort /tmp/sortdsk1
    x x  hdisk10
    x x hdisk1
    x x hdisk100
    y y  hdisk20
    y y hdisk2
    y y hdisk200
     $
    
    So the result above of 'sort -k3.6,3n /tmp/sortdsk1'
    seems to occur because sort encounters fields on some
    lines which have non-numeric characters and seems to
    abandon (without an error message) its effort to sort on
    the specified field.  Specifying the b modifier achieves
    better results:
    
     $ sort -k3.6b,3n /tmp/sortdsk1
    x x hdisk1
    y y hdisk2
    x x  hdisk10
    y y  hdisk20
    x x hdisk100
    y y hdisk200
     $
    
    But attempting to use the -b flag rather than the b
    modifier fails in the same way as 'sort -k3.6,3n
    /tmp/sortdsk1':
    
     $ sort -b -k3.6,3n /tmp/sortdsk1
    x x  hdisk10
    x x hdisk1
    x x hdisk100
    y y  hdisk20
    y y hdisk2
    y y hdisk200
    
    The sort result demonstrates that the -b  flag does not
    cause leading spaces and tabs to be ignored when finding
    the first of last column of a field.
    
    Example 2.
    A simple test shows that leading blanks are counted as
    part of the first field:
    
     $ cat /tmp/sorttest1
    a
     b
      c
    g
     h
      i
    d
     e
      f
     $
    
     $ sort -k1 /tmp/sorttest1
      c
      f
      i
     b
     e
     h
    a
    d
    g
     $
    
    If the b modifier is used to ignore leading blanks and
    tabs in the field, a different result is obtained:
    
     $ sort -k1b /tmp/sorttest1
    a
     b
      c
    d
     e
      f
    g
     h
      i
     $
    ---------------------------------
    
    The result from the above demonstrates that leading
    blanks are (by default) counted as part of the first
    field.
    

Local fix

  • n/a
    

Problem summary

  • Doc for sort was not clear.
    

Problem conclusion

  • Made appropriate changes.
    

Temporary fix

Comments

APAR Information

  • APAR number

    IZ49161

  • Reported component name

    AIX 5.3

  • Reported component ID

    5765G0300

  • Reported release

    530

  • Status

    CLOSED DOC

  • PE

    NoPE

  • HIPER

    NoHIPER

  • Submitted date

    2009-04-14

  • Closed date

    2009-04-14

  • Last modified date

    2009-04-14

  • APAR is sysrouted FROM one or more of the following:

  • APAR is sysrouted TO one or more of the following:

Fix information

Applicable component levels



Rate this page:

(0 users)Average rating

Add comments

Document information


More support for:

AIX family

Software version:

530

Operating system(s):

AIX

Reference #:

IZ49161

Modified date:

2009-04-14

Translate my page

Machine Translation

Content navigation