所以,我是 Ubuntu 20.04 的新用户,我一直在尝试弄清楚如何制作自己的命令。我一直在尝试使用一系列 if-then 语句来创建一个命令,以弄清楚它们是如何工作的,但我一直遇到同样的错误。这是代码:
echo "Would you like to see the secret? (Y/N)"
read AFFIRM
if [$AFFIRM == Y]; then
echo "Alright, but first I need to ask a few questions. Ready? (Y/N)"
read AFFIRM2
if [$AFFIRM2 == Y]; then
echo "Great. First, what is the name of this computer?"
read COMNAME
if [$COMNAME == thesynthetichuman -o $COMNAME == Computer X]; then
echo "Correct! Next question: What was the name of the first user on this computer?
read USERNAME
if [$USERNAME == synthetichuman]; then
echo "Correct again! Last question: What is your favorite color?"
read FAVCOLOR
echo $FAVCOLOR >> " eh? Nice. Here is the secret!
//ascii art
?IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII????????????IIIIIIIIIIIIIIIIIIIIIIIIIIIIIII?+++
?IIIIIIIIIIIIIIIIIIIIIIIIIII????++++++++++++++????IIIIIIIIIIIIIIIIIIIIIIIIIII+++
?IIIIIIIIIIIIIIIIIIIIIIII?++++++??????????????++++++?IIIIIIIIIIIIIIIIIIIIIIII+++
?IIIIIIIIIIIIIIIIIIIIIII?+++???????????????????????++IIIIIIIIIIIIIIIIIIIIIIII+++
?IIIIIIIIIIIIIIIIIIIIIII?+??????????????????????????+?IIIIIIIIIIIIIIIIIIIIIII+++
?IIIIIIIIIIIIIIIIIIIIIII?+??????????????????????????+?IIIIIIIIIIIIIIIIIIIIIII+++
?IIIIIIIIIIIIIIIIIIIIIII?+??????++??????????++??????+?IIIIIIIIIIIIIIIIIIIIIII+++
?IIIIIIIIIIIIIIIIIIIIIII?+??????++??????????++??????+?IIIIIIIIIIIIIIIIIIIIIII+++
?IIIIIIIIIIIIIIIIIIIIIII?+??????++??????????++??????+?IIIIIIIIIIIIIIIIIIIIIII+++
?IIIIIIIIIIIIIIIIIIIIIII++??????++??????????++??????+?IIIIIIIIIIIIIIIIIIIIIII+++
?IIIIIIIIIIIIIIIIIIIIIII++??????++??????????++??????+?IIIIIIIIIIIIIIIIIIIIIII+++
?IIIIIIIIIIIIIIIIIIIIIII++??????++??????????++??????++IIIIIIIIIIIIIIIIIIIIIII+++
?IIIIIIIIIIIIIIIIIIIIIII++??????++??????????++??????++IIIIIIIIIIIIIIIIIIIIIII+++
?IIIIIIIIIIIIIIIIIIIIIII++??????++??????????++??????++IIIIIIIIIIIIIIIIIIIIIII+++
?IIIIIIIIIIIIIIIIIIIIIII++??????++??????????++??????++IIIIIIIIIIIIIIIIIIIIIII+++
?IIIIIIIIIIIIIIIIIIIIIII++??????++??????????++??????++IIIIIIIIIIIIIIIIIIIIIII+++
?IIIIIIIIIIIIIIIIIIIIIII++??????++??????????++??????+?IIIIIIIIIIIIIIIIIIIIIII+++
?IIIIIIIIIIIIIIIIIIIIIII?+??????????????????????????+?IIIIIIIIIIIIIIIIIIIIIII+++
?IIIIIIIIIIIIIIIIIIIIIIII+++??????????????????????+++IIIIIIIIIIIIIIIIIIIIIIII+++
?IIIIIIIIIIIIIIIIIIIIIIII?+++++++????????????+++++++IIIIIIIIIIIIIIIIIIIIIIIII+++
?IIIIIIIIIIIIIIIIIIIIIIIIIIII???++++++++++++++???IIIIIIIIIIIIIIIIIIIIIIIIIIII+++
?IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII+++++++++++?IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII+++
?IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII+????????++?IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII+++
?IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII+++++++++++?IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII+++
?IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII+++++++++++?IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII+++
?IIIIIIIIIIIIIIIIIII?I???III?????+++??????+++?????????????IIIIIIIIIIIIIIIIIII+++
?IIIIIIIIIIIIIII?++++++++++++++++++++++++++++++++++++++++++++?IIIIIIIIIIIIIII+++
?IIIIIIIIIIIII??++??++????????????????????????++????????++??++??IIIIIIIIIIIII+++
?IIIIIIIIIIII+??????+???????????????????????+?++?????????+????+++IIIIIIIIIIII+++
?IIIIIIIIIII?+++????+???????++++??++++????????+++????????+????+++?IIIIIIIIIII+++
?IIIIIIIIIII+++++???+???????++++++++++????????+++????????+??++??+?IIIIIIIIIII+++
?IIIIIIIIIII+???+++++?????+++???++???+++????????+????????++++???+?IIIIIIIIIII+++
?IIIIIIIIIII+?????+++???????+???++???+??????????+????????+++????+?IIIIIIIIIII+++
?IIIIIIIIIII+++++???+????????+++??+++???????????+???????++???++++?IIIIIIIIIII+++
?IIIIIIIIIII+????+++++????????++++++????????+???+?++????+++++???++IIIIIIIIIII+++
?IIIIIIIIIII+???????++??????????++??????????????+???????++??????++IIIIIIIIIII+++
?IIIIIIIIIII+???????++++??????????????????????+++?????+++???????+?IIIIIIIIIII+++
?IIIIIIIIIII++++?????+??+?????????????????????+++???+++++?????+++?IIIIIIIIIII+++
?IIIIIIIIIII+?+++????+II?++++++???????????????+++++++?II+???++??++IIIIIIIIIII+++
?IIIIIIIIIII+?????++++IIII++++++++++++++++++++++++IIIIII++??????++IIIIIIIIIII+++
?IIIIIIIIIII++??????++IIII+++?????????????++++++++IIIIII+?????+++?IIIIIIIIIII+++
?IIIIIIIIIII+++++????+IIII+++++++????????????????+IIIIII+???+++++?IIIIIIIIIII+++
?IIIIIIIIIII+???++???+IIII+++?++++++++++++++++++++IIIIII+?+++???++IIIIIIIIIII+++
?IIIIIIIIIII??????++++IIII++??????????++++++++++++IIII??++++?????IIIIIIIIIIII+++
?IIIIIIIIIIIII??I???++IIII++++???????????????????+IIII??++???IIIIIIIIIIIIIIII+++
?IIIIIIIIIIIIIIIIIIII?IIII++????????++++++++++++++IIIIII?IIIIIIIIIIIIIIIIIIII+++
?IIIIIIIIIIIIIIIIIIIIIIIII+++????????????????????+IIIIIIIIIIIIIIIIIIIIIIIIIII+++
?IIIIIIIIIIIIIIIIIIIIIIIII++++++++??????????????++IIIIIIIIIIIIIIIIIIIIIIIIIII+++
?IIIIIIIIIIIIIIIIIIIIIIIII++?????+++++++++++++++++IIIIIIIIIIIIIIIIIIIIIIIIIII+++
+?????????????????????????+++????????+++++++++??++???????????????????????????+++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
GlassGiant.com"
else
echo "Wrong!"
fi
else
echo "Wrong!"
fi
elif [$AFFIRM == N]; then
echo "Okay then. Bye!"
else
echo "Look, I had very specific instructions. Why did you ignore them? Y or N. That is it. Come on."
fi
elif [$AFFIRM == N]; then
echo "Okay then. Bye!"
else
echo "Look, I had very specific instructions. Why did you ignore them? Y or N. That is it. Come on." // I seem to be getting "unexpected EOF while looking for matching `"'" errors on lines like this.
fi
echo "Bye!"
//syntax error: unexpected end of file???
我很困惑。EOF 错误出现在看似随机的行上,语法错误无论如何都会出现。我不明白如何修复错误,到目前为止我所有的谷歌搜索都是徒劳的。有人可以帮忙吗?
社交距离,我很无聊......
有语法错误,缺少引号,逻辑错误。
您必须逐行查看我所做的更改...在 if 语句中引用字符串时,我总是使用引号..在某些情况下您必须这样做。当你有嵌套的 ifs 时使用注释......正如提到的动荡......