欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

linux ubuntu bash shell报错 xxx.sh: Syntax error: end of file unexpected (expecting “then“)

程序员文章站 2022-05-30 16:39:03
...

代码:run.sh

# creat log dir if it not exists
logDir="./ckpt/"$timeDir
if [ ! -d $logDir  ]; then
  mkdir $logDir
else
  echo $logDir exist
fi

报错:

$ sh run.sh
: not foundrun.sh:
run.sh: 16: run.sh: Syntax error: end of file unexpected (expecting "then")

解决:
需要转换脚本编码方式

$ sudo apt-get install dos2unix
$ dos2unix run.sh

https://blog.csdn.net/qq_38989148/article/details/105340521

相关标签: Linux