新的bash腳本類型,並且遇到下面的代碼有問題。 我想數組數與數比較,你必須從「讀ANS」的問題大多比較小數bash腳本語句if語句,比較小數點
BGpercent=(0 99 99.3 99.6 99.8 100)
BGpoint=(0 1 2 3 4 5)
read ans
for ((c=${#BGpercent[@]}; c>=0; c--))
do
echo "${BGpercent[$c]}"
if [ "${BGpercent[$c]}" <= "$ans" ];
then
result=${BGpoint[$c]}
break
fi
done
echo $result | bc -lstrong text
Error - ./testscript.sh: =: No such file or directory
chmod 750 testscript.sh然後嘗試啓動它。另外,添加一個shebang。 – dood
不起作用,仍然有相同的錯誤 –
這部分消息'=:'很奇怪。 – 123