2020/12/07:Linux运行文件时报错:bash: $‘\r‘: command not found

遇到的问题

从windows打包写好的.sh文件拿到linux下解压缩运行,遇到了bash: $'\r': command not found错误。

发生错误的原因

这是因为Windows系统的文件换行使用的是\r\n,而Linux系统是\n

解决方法

# 使用vim打开文件
vim ***.sh
# 转换格式
:set ff=unix
# 保存文件
:wq

问题就解决了!

猜你喜欢

转载自blog.csdn.net/weixin_43624728/article/details/110835276