示例file.txt
:
100 foo
2 bar
300 tuu
当使用 sort -k 1,1 file.txt
时,行的顺序不会改变,尽管我们期待:
2 bar
100 foo
300 tuu
如何根据绝对数值对由数字组成的字段进行排序?
最佳答案
看看man page for sort ...
-n, --numeric-sort compare according to string numerical value
所以这里是一个例子......
sort -n filename
关于linux - 如何根据字段的数值对文件进行排序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4856030/