$' ': command not found 或者 syntax error: unexpected end of file 或者 syntax error near unexpected token `$' ''

执行shell脚本如果报如下错误:

syntax error near unexpected token `$' ''

syntax error: unexpected end of file

$' ': command not found

可能原因是写代码是编辑环境是window,或者Linux下的非Linux编码,

可以执行:dos2unix filename   来解决。

原文地址:https://www.cnblogs.com/yinguojin/p/10901216.html