打印小值时,如何使awk不使用科学计数法? [英] How can I make awk not use scientific notation when printing small values?

查看:273
本文介绍了打印小值时,如何使awk不使用科学计数法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在以下awk命令中

 awk '{sum+=$1; ++n} END {avg=sum/n; print "Avg monitoring time = "avg}' file.txt

要删除科学计数法输出(应该显示为1.5e-05的很小的值),我应该做什么更改?

what should I change to remove scientific notation output (very small values displayed as 1.5e-05) ?

我无法成功使用OMFT变量.

I was not able to succeed with the OMFT variable.

推荐答案

您应使用 printf AWK语句.这样,您可以指定填充,精度等.在您的情况下, %f 控制字母似乎更合适.

You should use the printf AWK statement. That way you can specify padding, precision, etc. In your case, the %f control letter seems the more appropriate.

这篇关于打印小值时,如何使awk不使用科学计数法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆