Convert floating point variable to integer?

bash, floating-point, integer

Solution

Assuming $myduration is a decimal or integer

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

Problem

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. How do I convert it to integer? ``` myduration=$(curl http://192.168.50.1/mantisbt/view.php?id=1 -w %{time_total}) > /dev/null ; \ [[ $myduration -gt 1 ]] && echo "`date +'%y%m%d%H%M%S' ``` It took more than 6 seconds to load the page `http://192.168.50.1/mantisbt/view.php?id=1`

Original source