Shell读取一个表达式并计算其结果

#!/bin/bash
# 读取一个算数表达式并计算出结果
# 如果输入
# 5+50*3/20 + (19*2)/7
# 则结果为
# 17.929

read x

printf "%.3f
" $(echo "scal=5;"$x |bc -l)

  

原文地址:https://www.cnblogs.com/ranwuer/p/8361770.html