sorting numbers with the sort command

核能气质少年 提交于 2020-01-06 06:59:44

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!