Bash学习:基础使用(长期更新)

版权声明:转载请注明出处! https://blog.csdn.net/oliverchu/article/details/79573221

使用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


猜你喜欢

转载自blog.csdn.net/oliverchu/article/details/79573221