Convert floating point variable to integer?

后端 未结 4 1241
粉色の甜心
粉色の甜心 2021-01-08 00:52

The shell script shown below will show a warning if the page takes more than 6 seconds to load. The problem is that the myduration variable is not an integer. H

4条回答
  •  别那么骄傲
    2021-01-08 01:34

    Assuming $myduration is a decimal or integer

    $ myduration=6.5
    $ myduration=$( printf "%.0f" $myduration )
    $ echo $myduration
    6
    

提交回复
热议问题