如何在shell脚本中进行浮点比较


#! /bin/sh
echo "Enter the first number: "
read a 
echo "Enter the second number: "
read b
if [ $a -eq $b ]
then 
echo "$a is larger Number"
else
echo "$b is larger Number"
fi

使用基本计算器命令bc怎么样?

#! /bin/sh
echo "Enter the first number: "
read a
echo "Enter the second number: "
read b
if (( $(echo "$a > $b" |bc -l) )); then
echo "$a is larger Number"
else
echo "$b is larger Number"
fi

相关内容

  • 没有找到相关文章

最新更新