sort
的-k
选项可能会出现多次。请尝试:
sort -t, -k6,6 -k4,4 inputfile
有关更多信息,请参阅sort invocation。
> ‘-k pos1[,pos2]’
> ‘--key=pos1[,pos2]’
Specify a sort field that consists of the part of the line between pos1 and pos2 (or the end of the line, if pos2 is omitted), inclusive.
Each pos has the form ‘f[.c][opts]’, where f is the number of the field to use, and c is the number of the first character from the beginning of the field. Fields and character positions are numbered starting with 1; a character position of zero in pos2 indicates the field's last character. If ‘.c’ is omitted from pos1, it defaults to 1 (the beginning of the field); if omitted from pos2, it defaults to 0 (the end of the field). opts are ordering options, allowing individual keys to be sorted according to different rules; see below for details. Keys can span multiple fields.
Example: To sort on the second field, use --key=2,2 (-k 2,2). See below for more notes on keys and more examples. See also the --debug option to help determine the part of the line being used in the sort.
欢迎来到stackoverflow,但你在谈论什么软件或编程语言? –
他正在谈论unix排序工具。 – XapaJIaMnu
@phresnel unix/linux shell – SheetJS