syntax error: unexpected "do" (expecting "fi")

在写脚本时,常常会遇到这样的报错提示,原因很简单,#! /bin/bash或/bin/sh时,对空格有严格的要求,比如查找某个文件是否存在:

#! /bin/bash
cd ~
cd /home/sts
path="/home/sts/temp"
if [  -f "$path"  ]
then
echo " path exist "
else
echo " not exist "
while [ true ]
do
echo " while *"
done
fi

注:特别要注意空格问题;

猜你喜欢

转载自www.cnblogs.com/xtrobot/p/12046693.html