BASH Case语句,语法错误(意外的文件结尾)

BASH Case语句,语法错误(意外的文件结尾),bash,syntax,case,Bash,Syntax,Case,我一直收到一个语法错误(意外的文件结尾)。语法在我看来很好,但这里显然有问题。我希望外部的人能够提供来自洞察的信息 read -p "Create default hosts file?: " yn case $yn in [Yy] ) echo "Creating default hosts file" sleep 1 cat <<-EOF1 > /etc/hosts

我一直收到一个语法错误(意外的文件结尾)。语法在我看来很好,但这里显然有问题。我希望外部的人能够提供来自洞察的信息

read -p "Create default hosts file?: " yn

       case $yn in
        [Yy] )  echo "Creating default hosts file"
            sleep 1
            cat <<-EOF1 > /etc/hosts
               Do not remove the following line, or various programs that  require network functionality will fail.
               127.0.0.1    localhost.localdomain localhost

               192.168.1.1      test01
               192.168.1.2      test02
               192.168.1.3      test03
               EOF1
                if [ "$(wc -m /etc/hosts)" == "215 /etc/hosts" ] ; then
               echo -e "Default Hosts file\e[1;32m COMPLETE \e[0m"     
            else
               echo -e "Default hosts file\e[1;31m FAILED \e[0m"
               sleep 1
               echo "Please correct before continuing"
               echo "EXITING..."
               sleep 1
               exit
            fi;;
        [Nn] )  echo 'Searching "/etc/hosts" for test03 entry'
            sleep 1
            grep "test03" /etc/hosts >/dev/null
            if [ "$?" -eq 0 ] ; then
               echo "Entry found!"
               echo "Setup Continuing..."
            else
               echo '"test03" entry not found'
               sleep 1
               echo "Please correct before continuing"
               sleep 1
               echo "EXITING..."
               sleep 1
               exit
            fi;;
         *   )  echo "Please answer [Yy] or [Nn].";;
       esac
read-p“创建默认主机文件”:“yn
案件$yn
[Yy])回显“创建默认主机文件”
睡眠1
cat/dev/null
如果[“$?”-等式0];然后
echo“找到条目!”
echo“安装程序正在继续…”
其他的
echo“找不到test03”条目
睡眠1
echo“继续前请更正”
睡眠1
回声“退出…”
睡眠1
出口
fi;;
*)回声“请回答[Yy]或[Nn]”;;
以撒

除制表符外,此处结尾文档标记应该是行上的第一个标记:

cat <<-EOF1 > /etc/hosts
           Do not remove the following line, or various programs that  require network functionality will fail.
           127.0.0.1    localhost.localdomain localhost

           192.168.1.1      test01
           192.168.1.2      test02
           192.168.1.3      test03
EOF1

cat它不一定是第一件事——它前面也可以有文本制表符(而不是空格),即
谢谢!结束此处结尾文档的EOF1在选项卡后有几个空格。我试着把它和最上面的标记对齐。。。