linux 中没有指数符号的序列生成

sequence generation without exponential notation in linux

您好,我正在尝试使用 seq 命令生成一个数字序列

seq  830456481  831456481

结果如下

8.30456e+08
8.30456e+08
8.30456e+08
8.30456e+08
8.30456e+08
8.30456e+08
8.30456e+08
8.30456e+08
8.30456e+08
8.30456e+08
8.30456e+08
8.30456e+08
8.30456e+08
8.30456e+08

不过,我希望使用指数符号以不同的格式将我的输出作为 belwo。

Expected output

830456481
830456482
830456483
......

我怎样才能实现它?

我的 seq(MacOS 上的 v 8.32 和 brew)默认情况下已经只打印数字(例如 830456481),所以我只是猜测。 man seq 提到了 -f 格式参数。你可以试试

seq  -f "%f" 830456481 830456485
830456481.000000
830456482.000000
830456483.000000
830456484.000000
830456485.000000

将“%g”作为格式传递给我您所看到的科学记数法。

seq  -f "%g" 830456481 830456485
8.30456e+08
8.30456e+08
8.30456e+08
8.30456e+08
8.30456e+08

格式参数没有很好的文档记录,您必须了解一些 C printf 函数才能正确使用。我可以指定“%.0f”来获得没有“.00000”的输出,就像普通的“%f”一样:

seq  -f "%.0f" 830456481 830456485
830456481
830456482
830456483
830456484
830456485