1、原因:脚本是在Windows下写的,Windows和Linux的换行符号不同,所以在Linux中执行脚本的时候报错。

2、查看:使用notepad++打开脚本,视图→ 显示符号→ 显示所有字符,如图所示,换行符是 CR LF,

但是Linux的是LF。

运行脚本:syntax error near unexpected token `$'{\r'

运行脚本:syntax error near unexpected token `$'{\r'

3、解决:在notepad++ 中,编辑→文档格式转换→转为Unix格式,然后再去Linux中运行脚本,就可以了。notepad++应该是大多数人必备的吧,就不需要去找别的类似于dos2unix的软件了。

运行脚本:syntax error near unexpected token `$'{\r'

相关文章:

  • 2021-09-26
  • 2022-12-23
  • 2021-07-09
  • 2021-08-30
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-12-16
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-30
  • 2021-04-24
相关资源
相似解决方案