我正在尝试创建一个将时间字符串转换为总分钟数的函数,即“11:22”将返回 682
str_to_min(){
ARR_T=$(echo $1 | tr ":" "\n")
HOUR=${ARR_T[0]}
MINUTE=${ARR_T[1]}
let MIN=(60*$HOUR)
let MIN=($MIN+$MINUTE)
#echo total minutes $MIN
return $MIN
}
str_to_min "11:22"
但我不断收到以下错误:
./find_service_to_display.sh: line 5: let: MIN=(60*11: missing )' (error token is "11")
./find_service_to_display.sh: line 6: let: MIN=(11: missing
)' (错误标记是“11”)