我试图用bash计算文件中某些数字的平均值。我知道awk
完全符合
awk '{s+=$1} END {print "Average: " s/NR}' file
但它只给我3位小数输出。虽然在某些情况下这已足够,但我需要7位小数。我怎么能这样做?
答案 0 :(得分:1)
打印值时,请使用printf
和适当的格式字符串:
awk '{ s += $1 } END { printf("%.7f\n", s/NR) }' file
答案 1 :(得分:0)
关注Sub Add_My_Data()
Application.ScreenUpdating = False
Dim i As Long
Dim lastrow As Long
Dim strTitle As String
lastrow = Sheets("TableData").Cells(Rows.Count, "A").End(xlUp).Row + 1
strTitle = Sheets("NewOrder").Cells(3, 1).Value
With Sheets("TableData")
.Cells(lastrow, 1).Value = strTitle
End With
Application.ScreenUpdating = True
End Sub
可能对您有帮助。
awk