【发布时间】:2013-06-07 21:40:37
【问题描述】:
我今天刚开始编写 bash 脚本,我需要一些帮助 :(
我有一个变量 $BE,如果它的值小于 75 或大于 89,那么我需要将值限制在这些数字上,所以我需要在其中添加一个 IF。
我的剧本可能一团糟,但正如我所说,这是我的第一个剧本。任何帮助都会很棒。该部分是制动菜单功能。
# Braking menu function
get_menu2 () {
dialog --title "Braking Calculator" --msgbox "Please Record the time to travel 5 metres then press OK" 15 40 ;
T=$(dialog --output-fd 1 --title "Braking Calculator" --inputbox "Please enter Time taken (in Seconds)" 9 30) ;
S=$(echo "scale=2; (18/$T)" |bc -l) ;
BE=$(echo "scale=2; (100-($S*1.86))"|bc -l) ;
D=$(echo "scale=1; ((0-($S/3.6))/(-1.19))"|bc -l) ;
dialog --title "Braking Calculator Results" --msgbox "
The speed is $S Km/h
The Min. Braking Eff. is $BE %
The Max.Stopping Distance is $D M" 15 40
get_menu1
} ;
【问题讨论】:
-
您能否考虑将您的代码摘录精简到相关部分? 您实际询问的是。这将大大提高您获得有用答案的机会。