Please help me understand how sort -k3,3 -k 4,4 short* works , is it sorting 3 and 4 th field ? what is the use of specifying 3,3 and 4,4 in sort and what is actually does and i see sort -k3 short* and sort -k3,3 -k 4,4 short* giving the same output.
Sort output attached
Please help
See man pages
Sort Key Definition Using the -k Flag
The -k KeyDefinition flag uses the following form:
-k [ FStart [ .CStart ] ] [ Modifier ] [ , [ FEnd [ .CEnd ] ][ Modifier ] ]
The sort key includes all characters beginning with the field specified by the FStart variable and the column specified by the CStart variable and ending with the field
specified by the FEnd variable and the column specified by the CEnd variable. If Fend is not specified, the last character of the line is assumed. If CEnd is not specified
the last character in the FEnd field is assumed. Any field or column number in the KeyDefinition variable may be omitted. The default values are:
FStart
Beginning of the line
CStart
First column in the field
FEnd
End of the line
CEnd
Last column of the field
If there is any spaces between the fields, sort considers them as separate fields.
The value of the Modifier variable can be one or more of the letters b, d, f, i, n, or r. The modifiers apply only to the field definition they are attached to and have the
same effect as the flag of the same letter. The modifier letter b applies only to the end of the field definition to which it is attached.
For example:
-k 3.2b,3r
specifies a sort key beginning in the second nonblank column of the third field and extending to the end of the third field, with the sort on this key to be done in reverse
collation order. If the FStart variable and the CStart variable fall beyond the end of the line or after the FEnd variable and the CEnd variable, then the sort key is
ignored.
Yes, a "sort short*" will be expanded by the shell, first, into sort followed by the list of files 'short*' expands to. The sort will concatenate them as input. The -k key options say sort by field three through three and then by field four through four, both ascending. Fields are defined by white space unless optioned otherwise, see 'man sort'.