当前位置: 技术问答>linux和unix
谁来帮我看看我这个简单的shell代码错在哪里了?
来源: 互联网 发布时间:2016-03-16
本文导语: 初学linux编程。谁来帮我看看我这个shell代码错在哪里了? #!/bin/bash #用户输入一个分数,程序给出相应的等级 echo "input a score of student:" read score if [$socre -gt 100] ;then echo "the score is invalidate!" elif [$socre -ge 90] ...
初学linux编程。谁来帮我看看我这个shell代码错在哪里了?
#!/bin/bash
#用户输入一个分数,程序给出相应的等级
echo "input a score of student:"
read score
if [$socre -gt 100] ;then
echo "the score is invalidate!"
elif [$socre -ge 90]
echo "Excellent!"
elif [$score -ge 80]
echo "Good!"
elif [$score -ge 70]
echo "Medium!"
elif [$score -ge 60]
echo "Passed"
else
echo "Failed"
fi
exit 0
请直接给出你修改后认为正确的代码。
#!/bin/bash
#用户输入一个分数,程序给出相应的等级
echo "input a score of student:"
read score
if [$socre -gt 100] ;then
echo "the score is invalidate!"
elif [$socre -ge 90]
echo "Excellent!"
elif [$score -ge 80]
echo "Good!"
elif [$score -ge 70]
echo "Medium!"
elif [$score -ge 60]
echo "Passed"
else
echo "Failed"
fi
exit 0
请直接给出你修改后认为正确的代码。
|
echo "input a score of student:"
read score
if [ $score -gt 100 ];then
echo "the score is invalidate!"
elif [ $score -ge 90 ];then
echo "Excellent!"
elif [ $score -ge 80 ];then
echo "Good!"
elif [ $score -ge 70 ];then
echo "Medium!"
elif [ $score -ge 60 ];then
echo "Passed"
else
echo "Failed"
fi
exit 0
给我加分啊 ! 我急需。
read score
if [ $score -gt 100 ];then
echo "the score is invalidate!"
elif [ $score -ge 90 ];then
echo "Excellent!"
elif [ $score -ge 80 ];then
echo "Good!"
elif [ $score -ge 70 ];then
echo "Medium!"
elif [ $score -ge 60 ];then
echo "Passed"
else
echo "Failed"
fi
exit 0
给我加分啊 ! 我急需。
|
正解,只要在每个elif后加上;then即可