带模的无效算术运算符(错误标记为“.5”)

带模的无效算术运算符(错误标记为“.5”)

简而言之,我想检查以下陈述是否属实:8 % 1.5 === 0.5

secondMatch=1.5
secondMatchResult=0.5

for element in "${array[@]}"
do
    COUNTER=$((COUNTER + 1))
    if [[ $(($COUNTER%3)) -eq 1 ]]
    then
       FILE_CONTENTS="$FILE_CONTENTSfile 'input.mp4'"
    elif [[ $(($COUNTER%$secondMatch)) -eq $secondMatchResult ]]
    then
       FILE_CONTENTS="$FILE_CONTENTS\ninpoint 3180"
    else
       FILE_CONTENTS="$FILE_CONTENTS\noutpoint 6000\n"
    fi
    echo "$element"
done

出现错误的失败行:

elif [[ $(($COUNTER%$secondMatch)) -eq $secondMatchResult ]]

完整错误:

 ./cut.sh: line 36: 2%1.5: syntax error: invalid arithmetic operator (error token is ".5")

nb 请忽略我的 bash 天赋 :(

相关内容