『练习』:
#!/bin/bash
read -p "Please input first number: " NUM1
read -p "Please input action: " ACTION
read -p "Please input second number: " NUM2
[ -z "$NUM1" -o -z "$ACTION" -o -z "$NUM2" ] && {
echo -e "\033[31mError input messages !!!\033[0m"
exit 1
}
bc << EOF
$NUM1 $ACTION $NUM2
EOF
Linux下的bc计算器(适合整数和小数计算)使用: