Get ceiling integer from number in linux (BASH)

后端 未结 13 1980
陌清茗
陌清茗 2020-12-01 04:54

How would I do something like:

ceiling(N/500)

N representing a number.

But in a linux Bash script

13条回答
  •  盖世英雄少女心
    2020-12-01 05:42

    Using the gorgeous 'printf' 1 will round up to the next integer

    printf %.0f $float
    or
    printf %.0f `your calculation formula`
    or
    printf %.0f $(your calculation formula)
    

    ref: how to remove decimal from a variable?

提交回复
热议问题