linux-tutorial/codes/shell/逻辑控制/bash-shell无法处理浮点数.sh

13 lines
275 B
Bash
Raw Normal View History

2019-10-29 18:22:19 +08:00
#!/usr/bin/env bash
2019-10-10 08:56:31 +08:00
2019-05-10 11:17:57 +08:00
#bash shell 仅能处理浮点数值,test命令无法处理val1变量中存储的浮点值
2019-10-10 08:56:31 +08:00
#testing floating point numbers
2019-05-10 11:17:57 +08:00
val1=`echo "scale=4; 10 / 3" | bc`
echo "The test value is $val1"
if [ $val1 -gt 3 ]
then
2019-10-29 18:22:19 +08:00
echo "The result is larger than 3"
2019-05-10 11:17:57 +08:00
fi