"Joseph A. Wiencko, Jr." <[EMAIL PROTECTED]> writes: | Hello, | | I would like to report a bug in the sort routine. | | I have an application I am transitioning from another machine and | operating system. The new OS uses the following sort routine: | sort (GNU textutils) 2.0 | Written by Mike Haertel. | | The problem occurs when sorting a text file such as the following: | | 47259 204.111.53.2 3075 0943844493 sb 0943841196 | 16227 204.111.49.4 1028 0943793796 s_k 0943791903 | 16245 204.111.49.4 2817 0943804113 s_k 0943794149 | 235930186 204.111.53.2 3601 0943803326 sk 0943803087 | 16418 204.111.49.4 770 0943813181 s_k 0943805896 | 16737 204.111.49.4 1283 0943824264 s_k 0943822788 | 16773 204.111.49.4 2050 0943826902 s_k 0943824489 | 16933 204.111.49.4 1796 0943833022 s_k 0943832405 | 235406064 204.111.53.2 3593 0943843088 sk 0943837975 | 235602212 204.111.49.4 3596 0943841979 s_k 0943841068 | | Suppose I want to sort this according to the 5th field (sb, s_k, sk) Here are two ways to sort on the 5th field The posix way: sort -k5,5 The old way: sort +4 -5 | Let's call a file containing the above lines "x". | The following do not work correctly: These are all wrong: This sorts on fields 3 through the end of line. | sort +4 x This sorts on fields 5 through the end of line. | sort -k 5 x This sorts on fields 5 and 6. | sort -k 5,6 x | The following works correctly: | | sort -k 5,5 x | | | The "sort +4 x" is of course the obsolescent form. Since the definition | of "obselescent" is "almost, but not yet, obsolete", it seems that this | should work (or this form should be listed as "obsolete". The form | "sort -k 5 x" should work, because the second parameter for the -k | option is listed as optional. The form "sort -k 5,6 x" should work True, the POS2 arg is optional, but if you omit it, then sort assumes you want to use everything from POS1 to the end of the line as the sort key. | correctly, sorting on both the 5th and 6th fields, but it sorts on | neither of these.