Get ceiling integer from number in linux (BASH)

后端 未结 13 1967
陌清茗
陌清茗 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:53

    Without specifying any function, we can use the following awk script:

    echo x y | awk '{ r=$1 % $2; q=$1/y; if (r != 0) q=int(q+1); print q}'
    

    Not sure this one get any logical error or not. Please correct.

提交回复
热议问题