问题
I would like to sort the values in the following file numbers.txt, below is an example
1.1
1.2
10.0
2.2
1000.0
However when I execute the following cmd
sort numbers.txt
I get the following:
1.1
1.2
10.0
1000.0
2.2
What cmd to I need to sort the numeric values appropriately?
回答1:
Use the -n
flag to sort numerically, instead of lexicographically:
sort -n numbers.txt
来源:https://stackoverflow.com/questions/12764690/sorting-numbers-with-the-sort-command