Subject: | |
From: | |
Reply To: | |
Date: | Thu, 7 Nov 2013 23:43:12 +0000 |
Content-Type: | text/plain |
Parts/Attachments: |
|
|
In message <[log in to unmask]>, Olav Kappert
<[log in to unmask]> writing at 16:32:19 in his/her local time
opines:-
>I would like to know the background for how the Unix sort works with keys.
>
>The cmd is --- sort -t \& -o outfile -k 1.1,1.12 filea fileb ---
>
>where filea and fileb are the input files and they are both 80 bytes in
>length or in the unix world as byte stream.
>
>Since there is no "&" character in the file, it will treat the whole
>record as one field.
>
>When looking at the data, it seems that the key was actually extended
>for the length of the record or data while it should only be looking at
>the 12 bytes in the key.
>
>This behavour is counter to the chronical order of the information
>placed in the file.
>
>Does anyone have a solution as to how to sort/merge the files and
>retain the chronical order otherwise ?
>
>~~~~~
>Just to make it interesting I also get the following message:
>
> sort: Warning: A newline character was added to the end of the input.
>
>for each record sorted/merged.
>
>Why and how do you get rid of this message other than redirecting it to
>$null.
>
>Olav.
Could it be that you aren't getting a stable sort, so the output
ordering of records with the same key but different following data is
undefined?
(Even if the sort takes the opportunity of 'undefined' to use a complete
record sort?)
If so, try adding the -s option to force a stable sort.
Or maybe you need k=1.1,1.12 according to the man page I'm reading, and
you don't quote an = sign above? In which case it may be that the
default for 'no -k' is also being taken for '-k apparently on its own',
and that default is to sort the whole record.
Or maybe you even need both things I mention?
Roy
--
Roy Brown 'Have nothing in your houses that you do not know to be
Kelmscott Ltd useful, or believe to be beautiful' William Morris
* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *
|
|
|