linux运行shell脚本报错,提示syntax error near unexpected token `$'{\r''异常

发布时间 2023-03-30 15:35:52作者: yjry-th

最近运行一个shell脚本的时候,发现报syntax error near unexpected token `$’{\r’’ error。字面意思上看是换行符出现问题

用vim -b 查看,发现每一行多了~M
解决方法:
sed -i 's/\r//g' xxx.sh
这样脚本就可以运行了
————————————————
原文链接:https://blog.csdn.net/lililidahaoren/article/details/124266906