我希望table
使用在第二个字段中找到的数值对空格分隔进行排序。我可以假设第二个字段总是 fooN 但 N 的长度是未知的:
antiq. foo11 girls
colleaguing foo2 Leinsdorf
Cousy foo0 Montgomeryville
bowlegged foo1 pollack
Chevrier foo10 ill-conceived
candlebomb foo3 seventieths
autochthony foo101 re-enable
beneficiate foo100 osteometric
我阅读man sort(1)
并玩了各种选择。在我的系统上,我找到了这条线:
sort -n -k2.5 table
去工作。
我的问题是为什么?
根据手册页:
-k, --key=POS1[,POS2]
start a key at POS1, end it at POS 2 (origin 1)
...
POS is F[.C][OPTS], where F is the field number and C the characterposition in the
field. OPTS is one or more single-letter ordering options, which override global
ordering options for that key. If no key is given, use the entire line as the key.
那么为什么sort -n -k2.4
表格不起作用并且起作用sort -n -k2.5
呢?