Bash:用指数对数字进行排序

标签 bash sorting command-line

我试图用这样的数值对一个文件进行排序:

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

通过排序,所有数字都得到排序,除了带有指数的数字,排序函数是否有某种方法来计算这个表达式?

最佳答案

如果你的排序命令版本足够新,它应该支持 -g 选项(或者 --general-numeric-sort) 如果你喜欢你的选项长的)。在信息手册中是这样描述的:

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'.

关于Bash:用指数对数字进行排序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4324923/

相关文章:

windows - 如何识别Windows dir命令中的日期格式?

java - 使用 spark-submit 时出现 "The filename, directory name, or volume label syntax is incorrect."

bash - 如何将 Emacs 缓冲区中的内容通过管道传输到外部程序,并打印结果?

bash - 使用 Bash 安排 Cron

javascript - 翻译正则表达式

java - Collections.sort() throws 比较方法违反了它的一般约定!异常(exception)

bash - 计算多个文件中某个字段的唯一出现次数

Java 用线程对单词数组进行排序

c# - C#中的自然数字排序

visual-studio-2008 - 运行MSBuild,尊重已卸载的项目