Sorting numbers with multiple decimals in bash

后端 未结 3 670
野性不改
野性不改 2020-12-20 14:51

In bash using sort with the -n option doesn\'t give me the expected result.

$ cat numbers | sort -n
1.0
1.1
1.11.4
1.         


        
3条回答
  •  悲&欢浪女
    2020-12-20 15:31

    sort -g numbers
    

    It will do. As per sort man page, -g is meant for numerical sorting:

    -g, --general-numeric-sort

    compare according to general numerical value

提交回复
热议问题