一、 shell脚本执行错误 $’\r’:command not found
场景:
Windows下编写的linux .sh脚本在linux服务器上执行出现此错误
原因:
脚本在执行中无法识别\r
Linux采用\n为换行
Windows采用\r\n为换行
Mac采用\r为换行
解决方法一:
安装dos2unix将换行符转换为linux换行符
# 安装
yum install dos2unix -y
# 转换
dos2unix *.sh
解决方法二:
使用010editor进行手动替换。
————————————————