因为脚本中存在Windows风格的换行符(\r\n)出现xx.sh: line 9: syntax error near unexpected token $'\r''

这个错误是因为脚本中存在Windows风格的换行符(\r\n)。

使用sed命令删除\r字符

可以使用sed命令来删除脚本中的\r字符:

sed -i 's/\r$//' xx.sh
posted @ 2024-07-05 16:23  jaycheney  阅读(84)  评论(0)    收藏  举报