ber@enea.UUCP (07/07/83)
Can anyone explain why sort (version 4.2 in Berkeley 4.1) seems to include the fiel separation character in the sorting. Well, anyhow in this case. If a file contains a#b a1#b a2#b and one sorts this with sort -t# file the output is identical with that in the file. But if I change all the #'s to :'s, and then sort -t: file, the output is a1:b a2:b a:b (observing that #<1<2<:). I would expect the same result regardless of the delimiter used. Bjorn Eriksen (...!mcvax!enea!ber)
guy@rlgvax.UUCP (07/09/83)
This ("sort" including the field separator in its comparisons) is an old old old old old "sort" bug, going all the way back to V6! It's still in V7 (and hence in 4.1BSD), and still in System III, and I suspect it may still be in System V. Obviously (:->) it must be a *feature*, not a bug. Or maybe the word is "misfeature"? Anybody out there, from the Bell UNIX group or elsewhere, know WHY this hasn't been changed even though at least 6.02E23 people have found it? *Is* it supposed to work that way, and if so, WHY? Guy Harris {seismo,mcnc,we13,brl-bmd,allegra}!rlgvax!guy
jpl@eagle.UUCP (John P. Linderman) (07/09/83)
I had trouble with mail, so I'm posting this to the net. The problem with sort -t: is that it specifies a field separator, but specifies no fields. Sort just reverts to its default of using the entire line. The effect you are probably after can be obtained by sort -t: +0 -1 +1 -2 ... One might argue that that would make a good default when a -t is given but no fields are mentioned. Peeking into how sort works reveals that it isn't is easy as one would hope, so the moral is, if you use -t, specify some fields. John P. Linderman eagle!jpl Department of Total Disorder