我不断收到语法错误(文件意外结束)。语法对我来说看起来不错,但这里显然有问题。我希望外面的人可以提供洞察力。
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