-k1,1
in the command
sort -k1,1 input.txt
would sort on the data using first column as the sorting key, only. The first 1
denotes the start of the sorting key as column 1, and the second 1
denotes the same column as the end of the sorting key. Had you used -k1
or -k1,2
on a file with two columns, then both columns would have been used (as would have been the case if -k
was not used on the command line at all).
In short, the two digits refer to the sorting key's start and end column.
So, using -k1,1
will only use the first of your two columns as the sorting key. When two rows have the same key, however, the whole line will be used to determine the order of the two lines (unless another -k
option is specified after the first, in which case that will be used before the whole line is used).
man sort
and look for the-k
flag... and then search further down for theKEYDEF
that it refers to. – roaima Jan 25 '19 at 21:51man
'ed it. – anonuser01 Jan 25 '19 at 21:54--debug
option is nice. – Jeff Schaller♦ Jan 25 '19 at 23:17