I have read Trying to sort on two fields, second then first. I am still confused.
In the man sort
page:
KEYDEF is F[.C][OPTS][,F[.C][OPTS]] for start and stop position
Why there are two OPTS
?
Does it mean you can write OPTS
at any place? Or do the two OPTS
affect different fields?
But isn't the key (e.g. -k3,5
) function as a whole?
What will happen if the two OPTS
are opposite? Such as:
sort -t " " -k3n,5nr filename
The other question is that -k3n,5nr
contains two white-spaces, how can the shell translate that into a number?
When we want to compare multi fields, should we use multi -k
(e.g. -k3
-k4
-k5
)? Is -k3n,5n
wrong?