Bash 语法错误:文件意外结束 [英] Bash syntax error: unexpected end of file
本文介绍了Bash 语法错误:文件意外结束的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
请原谅我这是一个非常简单的 Bash 脚本.代码如下:
Forgive me for this is a very simple script in Bash. Here's the code:
#!/bin/bash
# june 2011
if [ $# -lt 3 -o $# -gt 3 ]; then
echo "Error... Usage: $0 host database username"
exit 0
fi
运行sh file.sh后:
after running sh file.sh:
语法错误:文件意外结束
syntax error: unexpected end of file
推荐答案
我认为 file.sh 带有 CRLF 行终止符.
I think file.sh is with CRLF line terminators.
运行
dos2unix file.sh
那么问题就解决了.
您可以使用以下命令在 ubuntu 中安装 dos2unix:
You can install dos2unix in ubuntu with this:
sudo apt-get install dos2unix
这篇关于Bash 语法错误:文件意外结束的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文