我正在尝试运行一个脚本,在该脚本中,每次在while循环中使用浮点数字“作为用户输入的值”来更新变量。我知道bash不支持浮点数,我尝试使用|卑诗省,但对我来说似乎无效...
step_l0=0.25
step_l=0
while [ $step_l -le 2 ] do
step_r=$radius_input
while [ $step_r -le $radius_define ] do
stuff done in the while loops
step_r=$(( $step_r + $step_r0 ))
done
step_l=$(( $step_l + $step_l0 ))
done
根据chepner的建议-
$: a=0.25
$: b=1.753
$: awk "BEGIN{ print $a + $b }"
2.003
$: python -c "print $a + $b"
2.003
$: perl -e "print $a + $b"$'\n'
2.003