linux - 我的代码给出错误 : ./greeting2.sh: line 11: syntax error: unexpected end of file

标签 linux bash ubuntu

<分区>

伙计们,我是学习 bash 脚本的初学者,我不知道那是什么错误,我正在使用最新的 Ubuntu LTS,它给出了这个错误: ./greeting2.sh: 第 11 行:语法错误:意外的文件结尾

代码如下:

#!/bin/bash

echo -n "Hello, what is your name? "
read firstname
echo -n "Thank you, and what is your surname? "
read surname
clear
if [ "$firstname" == "Your name" ] && [ "$surname" == "Your surname" ]
then echo "Awesome name, " $firstname $surname
else echo You are not allowed to go!

最佳答案

末尾缺少fi

#!/bin/bash
echo -n "Hello, what is your name? "
read firstname
echo -n "Thank you, and what is your surname? "
read surname
clear
if [ "$firstname" == "Your name" ] && [ "$surname" == "Your surname" ]
then echo "Awesome name, " $firstname $surname
else echo You are not allowed to go!
fi

关于linux - 我的代码给出错误 : ./greeting2.sh: line 11: syntax error: unexpected end of file,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52007839/

相关文章:

linux - 匹配时如何退出 Sed

arrays - 检查 Bash 数组是否包含值

python - 手动安装python分发包出现IOError : CRC check failed

python - Ubuntu、cx_Freeze 和 multiprocessing.Manager() 在 "spawn"类型进程的情况下发生冲突

程序输出可以通过程序本身重定向到管道吗?

linux - Bash:为什么我的 If 语句总是评估为真?

linux - 通过 cron 为 django 运行 python 脚本

ubuntu - 如何让 LaTeX 在 IPython notebook 中工作?

linux - 无法理解 setuid/setgid

linux - 复制文件和文件夹并通过 shell 脚本合并