Get ceiling integer from number in linux (BASH)

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

    Call out to a scripting language with a ceil function. Given $NUMBER:

    python -c "from math import ceil; print ceil($NUMBER/500.0)"
    

    or

    perl -w -e "use POSIX; print ceil($NUMBER/500.0), qq{\n}"
    

提交回复
热议问题