Bash: sort numbers with exponents

前端 未结 4 594
离开以前
离开以前 2021-02-07 03:25

I was trying to sort one file with numeric values like this:

414e-05
435e-05
0.5361
0.7278
0.1341
0.9592
0.2664

With sort all the numers get so

4条回答
  •  悲&欢浪女
    2021-02-07 04:10

    If your version of the sort command is new enough, it should support the -g option (or --general-numeric-sort) if you like your options long). It is described like this in the info manual:

    Sort numerically, using the standard C function strtod to convert a prefix of each line to a double-precision floating point number. This allows floating point numbers to be specified in scientific notation, like '1.0e-34' and '10e100'.

提交回复
热议问题