使用Linux的过程中,我们学会一些批处理是对我们的高校办公有帮助的
if语句:
#!/bin/bash echo "Please input a integer(0-100):" read score if [ "$score" 0 -o "$score" -gt 100 ] then echo "The score what you input is not a integer or the score is not in (0-100)." elif [ "$score" -ge 90 ] then echo "The grade is A." elif [ "$score" -ge 80 ] then echo "The grade is B." elif [ "$score" -ge 70 ] then echo "The grade is C." elif [ "$score" -ge 60 ] then echo "The grade is D." else echo "The grade is E." fi案例:
#!/bin/bash # 启动另一版本的Android Studio echo "What do you want to do next?" echo "-1 Run Android Studio 3.0" echo "-2 Run Android Studio 3.0 background" read sel if [ "$sel" -eq 1 ] then bash /usr/local/android-studio/bin/studio.sh echo "Android studio 3.0 has been started." elif [ "$sel" -eq 2 ] then nohup bash /usr/local/android-studio/bin/studio.sh >/dev/null 2>&1 & echo "Android studio 3.0 has been started." fi