【发布时间】:2015-11-23 23:11:05
【问题描述】:
你的名字的脚本
#!/bin/bash
echo "what is your name?"
read name
if test "$name" = "Daryl"
then
echo "Hey, how are you?"
else
echo "sorry, im looking for Daryl"
fi
你的成绩脚本
#!/bin/bash
./yourname
if[ 0 -eq "$?" ]
then
exit 0
else
echo "what is your grade?"
read grade
if [ "$grade" -gt 90 ]
then
echo "Awesome! You got an A"
elif [ "$grade -le 90 ] && [ "$grade" -gt 80 ]
then
echo "Good! You got a B"
elif [ "$grade" -lt 80 ];
then
echo "You need to work harder!"
fi
我正在尝试获取它,以便在 yourGrade 脚本中使用你的名字检查它是否是 Daryl,如果不是则停止程序。然后如果是询问成绩,则读取成绩值并根据成绩返回相应的消息。
每次我运行它我都会得到......
root@kali:~# . yourGrade
What is your name?
>Daryl
Hey how are you!
-bash : yourGrade: line 17: syntax error near unexpected token 'elif'
-bash : yourGrade: line 17:' elif [ "$grade" -le 90 ] && [ "$grade" -gt 80 ]'
任何帮助将不胜感激!
【问题讨论】:
-
感谢您的帮助,我是这方面的新手,所以这真的很有帮助!