Convert floating point variable to integer?
问题 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 回答1: Assuming $myduration is a decimal or integer $ myduration=6.5 $