Shell – How to round or convert a float value to int with bc? getting: “(standard_in) 1: syntax error”

bcconversionfloating pointshell-scriptvariable

I will get value like 2743410360.320 and I want value like 2743410360 to a variable.

I tried

INTValueOfGB=$ echo "($gb+0.5)/1" | bc

But I am getting (standard_in) 1: syntax error

Best Answer

You can use printf for rounding:

$ printf "%.0f" 2743410360.320
Related Question