I'm starting to learn about writing scripts for the bash terminal, but I can't work out how to get the comparisons to work properly.
(我开始学习有关为bash终端编写脚本的知识,但是我无法弄清楚如何使比较正常工作。)
The script I'm using is: (我使用的脚本是:)
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?
(如何将数字转换为类型以进行真正的比较?)
ask by advert2013 translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…