how to remove decimal from a variable?

前端 未结 2 520
情深已故
情深已故 2021-02-05 16:28

how to remove decimal place in shell script.i am multiplying MB with bytes to get value in bytes .I need to remove decimal place.

ex:-
196.3*1024*1024
205835468         


        
2条回答
  •  旧时难觅i
    2021-02-05 16:57

    Use printf:

    printf %.0f $float
    

    This will perform rounding. So if float is 1.8, it'll give you 2.

提交回复
热议问题