問題:
I'm unable to get numeric comparisons working:我無法進行數字比較:
echo "enter two numbers";
read a b;
echo "a=$a";
echo "b=$b";
if [ $a \> $b ];
then
echo "a is greater than b";
else
echo "b is greater than a";
fi;
The problem is that it compares the number from the first digit on, ie, 9 is bigger than 10, but 1 is greater than 09.問題是它從第一位開始比較數字,即9大於10,但1大於09。
How can I convert the numbers into a type to do a true comparison?如何將數字轉換爲類型以進行真正的比較?
解決方案:
參考一: https://en.stackoom.com/question/1GKXk參考二: https://stackoom.com/question/1GKXk