Hi everyone,
I use the sort from the 5.3.0 coreutils package. I have a file consisting in 5 fields
separated by a single space, with no leading or trailing blanks.
I want to sort it first according to the 4th field, which contains integers
(some of them negative), and secondly on the second field, which is a string
(i.e. if two lines have the same value for the 4th field I want them sorted according
to the second field).
After reading the man page and the info page I came up with
sort sort -k 4,4n -k 2,2 correspondance_tmp
(where correspondance_tmp is my file), but this seems not to work because
when I ask it to check if the result is sorted according to the 4th field it says
no. So I think I must not know how to specify the fields properly.
Here is a short extract from my working session:
$ sort -k 4,4n -k 2,2 correspondance_tmp > correspondance
$ sort -c -k4,4n correspondance
sort: correspondance:37: disorder: . 0-00.com 1 -1 43
$ cat correspondance | awk '{print $4}' | sort -cn
$
This last check of sortedness exists without error, which means the
corresponding file is correctly sorted.
The line about which sorts complains in file correspondance is in
a large group of lines all having -1 for 4th field, so it seems to be
correctly placed.
All my locales are set to "C".
If anyone has any advice I'd greatly appreciate.